[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 12/22] virtio-9p: avoid unwarranted use of strnc
From: |
Aneesh Kumar K.V |
Subject: |
Re: [Qemu-devel] [PATCH 12/22] virtio-9p: avoid unwarranted use of strncpy |
Date: |
Wed, 09 May 2012 18:37:50 +0530 |
Jim Meyering <address@hidden> writes:
> From: Jim Meyering <address@hidden>
>
> The use of strncpy in mp_user_listxattr is unnecessary, since we
> know that the NUL-terminated source bytes fit in the destination
> buffer. Use memcpy in place of strncpy.
>
> Signed-off-by: Jim Meyering <address@hidden>
May be this can be folded into the earlier patch ?
Reviewed-by: Aneeseh Kumar K.V <address@hidden>
> ---
> hw/9pfs/virtio-9p-xattr-user.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/hw/9pfs/virtio-9p-xattr-user.c b/hw/9pfs/virtio-9p-xattr-user.c
> index 5044a3e..5bb6020 100644
> --- a/hw/9pfs/virtio-9p-xattr-user.c
> +++ b/hw/9pfs/virtio-9p-xattr-user.c
> @@ -61,7 +61,8 @@ static ssize_t mp_user_listxattr(FsContext *ctx, const char
> *path,
> return -1;
> }
>
> - strncpy(value, name, name_size);
> + /* name_size includes the trailing NUL. */
> + memcpy(value, name, name_size);
> return name_size;
> }
>
> --
> 1.7.10.1.487.ga3935e6
- [Qemu-devel] strncpy: best avoided (resend), Jim Meyering, 2012/05/09
- [Qemu-devel] [PATCH 09/22] ui/vnc: simplify and avoid strncpy, Jim Meyering, 2012/05/09
- [Qemu-devel] [PATCH 10/22] bt: replace fragile snprintf use and unwarranted strncpy, Jim Meyering, 2012/05/09
- [Qemu-devel] [PATCH 12/22] virtio-9p: avoid unwarranted use of strncpy, Jim Meyering, 2012/05/09
- Re: [Qemu-devel] [PATCH 12/22] virtio-9p: avoid unwarranted use of strncpy,
Aneesh Kumar K.V <=
- [Qemu-devel] [PATCH 06/22] os-posix: avoid buffer overrun, Jim Meyering, 2012/05/09
- [Qemu-devel] [PATCH 01/22] block: avoid buffer overrun by using pstrcpy, not strncpy, Jim Meyering, 2012/05/09
- [Qemu-devel] [PATCH 18/22] acpi: remove strzcpy (strncpy-identical) function; just use strncpy, Jim Meyering, 2012/05/09
- [Qemu-devel] [PATCH 22/22] doc: update HACKING wrt strncpy/pstrcpy, Jim Meyering, 2012/05/09
- [Qemu-devel] [PATCH 11/22] virtio-9p: avoid unwarranted uses of strncpy, Jim Meyering, 2012/05/09