All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shannon Zhao <zhaoshenglong@huawei.com>
To: Paolo Bonzini <pbonzini@redhat.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-trivial] [PATCH] hw/9pfs/virtio-9p-proxy: Fix possible overflow
Date: Sat, 14 Mar 2015 09:19:23 +0800	[thread overview]
Message-ID: <55038C9B.7050607@huawei.com> (raw)
In-Reply-To: <5502DD26.6070401@redhat.com>

On 2015/3/13 20:50, Paolo Bonzini wrote:
> 
> 
> 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.
> 

Thanks, will fix along with the other patch.

-- 
Thanks,
Shannon



WARNING: multiple messages have this Message-ID (diff)
From: Shannon Zhao <zhaoshenglong@huawei.com>
To: Paolo Bonzini <pbonzini@redhat.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: Sat, 14 Mar 2015 09:19:23 +0800	[thread overview]
Message-ID: <55038C9B.7050607@huawei.com> (raw)
In-Reply-To: <5502DD26.6070401@redhat.com>

On 2015/3/13 20:50, Paolo Bonzini wrote:
> 
> 
> 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.
> 

Thanks, will fix along with the other patch.

-- 
Thanks,
Shannon

  reply	other threads:[~2015-03-14  1:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-13 11:09 [Qemu-trivial] [PATCH] hw/9pfs/virtio-9p-proxy: Fix possible overflow Shannon Zhao
2015-03-13 11:09 ` [Qemu-devel] " Shannon Zhao
2015-03-13 12:50 ` [Qemu-trivial] " Paolo Bonzini
2015-03-13 12:50   ` [Qemu-devel] " Paolo Bonzini
2015-03-14  1:19   ` Shannon Zhao [this message]
2015-03-14  1:19     ` Shannon Zhao
2015-03-16  7:58 ` [Qemu-trivial] " Aneesh Kumar K.V
2015-03-16  7:58   ` [Qemu-devel] " Aneesh Kumar K.V
2015-03-16  9:30   ` [Qemu-trivial] " Shannon Zhao
2015-03-16  9:30     ` [Qemu-devel] " 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=55038C9B.7050607@huawei.com \
    --to=zhaoshenglong@huawei.com \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=hangaohuai@huawei.com \
    --cc=mjt@tls.msk.ru \
    --cc=pbonzini@redhat.com \
    --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 \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.