From: Paolo Bonzini <pbonzini@redhat.com>
To: Shannon Zhao <zhaoshenglong@huawei.com>, qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, hangaohuai@huawei.com,
qemu-trivial@nongnu.org, mjt@tls.msk.ru,
peter.huangpeng@huawei.com, aneesh.kumar@linux.vnet.ibm.com,
shannon.zhao@linaro.org
Subject: Re: [Qemu-devel] [PATCH] hw/9pfs/virtio-9p-proxy: Fix possible overflow
Date: Fri, 13 Mar 2015 13:50:46 +0100 [thread overview]
Message-ID: <5502DD26.6070401@redhat.com> (raw)
In-Reply-To: <1426244956-5316-1-git-send-email-zhaoshenglong@huawei.com>
On 13/03/2015 12:09, Shannon Zhao wrote:
> + g_assert(strlen(path) < sizeof(helper.sun_path));
Ok.
> sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
> if (sockfd < 0) {
> fprintf(stderr, "failed to create socket: %s\n", strerror(errno));
> return -1;
> }
> - strcpy(helper.sun_path, path);
> + strncpy(helper.sun_path, path, sizeof(helper.sun_path));
strcpy is okay here. strncpy makes people think of what happens if
strlen(path) == sizeof(helper.sun_path). While this cannot happen here
because of the assertion, the function should still be used with care.
Paolo
next prev parent reply other threads:[~2015-03-13 12:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-13 11:09 [Qemu-devel] [PATCH] hw/9pfs/virtio-9p-proxy: Fix possible overflow Shannon Zhao
2015-03-13 12:50 ` Paolo Bonzini [this message]
2015-03-14 1:19 ` Shannon Zhao
2015-03-16 7:58 ` Aneesh Kumar K.V
2015-03-16 9:30 ` Shannon Zhao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5502DD26.6070401@redhat.com \
--to=pbonzini@redhat.com \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=hangaohuai@huawei.com \
--cc=mjt@tls.msk.ru \
--cc=peter.huangpeng@huawei.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=shannon.zhao@linaro.org \
--cc=zhaoshenglong@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).