[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] hw/9pfs/virtio-9p-proxy: Fix possible overflow
From: |
Shannon Zhao |
Subject: |
Re: [Qemu-devel] [PATCH] hw/9pfs/virtio-9p-proxy: Fix possible overflow |
Date: |
Sat, 14 Mar 2015 09:19:23 +0800 |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 |
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