[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 11/22] virtio-9p: avoid unwarranted uses of strn
From: |
Aneesh Kumar K.V |
Subject: |
Re: [Qemu-devel] [PATCH 11/22] virtio-9p: avoid unwarranted uses of strncpy |
Date: |
Wed, 09 May 2012 18:38:04 +0530 |
Jim Meyering <address@hidden> writes:
> From: Jim Meyering <address@hidden>
>
> In both mp_pacl_listxattr and mp_dacl_listxattr, the uses of strncpy
> were unnecessary, since at each point of use 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>
Acked-by: Aneesh Kumar K.V <address@hidden>
> ---
> hw/9pfs/virtio-9p-posix-acl.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/hw/9pfs/virtio-9p-posix-acl.c b/hw/9pfs/virtio-9p-posix-acl.c
> index a1948e3..c064017 100644
> --- a/hw/9pfs/virtio-9p-posix-acl.c
> +++ b/hw/9pfs/virtio-9p-posix-acl.c
> @@ -44,7 +44,8 @@ static ssize_t mp_pacl_listxattr(FsContext *ctx, const char
> *path,
> return -1;
> }
>
> - strncpy(value, ACL_ACCESS, len);
> + /* len includes the trailing NUL */
> + memcpy(value, ACL_ACCESS, len);
> return 0;
> }
>
> @@ -95,7 +96,8 @@ static ssize_t mp_dacl_listxattr(FsContext *ctx, const char
> *path,
> return -1;
> }
>
> - strncpy(value, ACL_DEFAULT, len);
> + /* len includes the trailing NUL */
> + memcpy(value, ACL_ACCESS, len);
> return 0;
> }
>
> --
> 1.7.10.1.487.ga3935e6
- Re: [Qemu-devel] [PATCH 12/22] virtio-9p: avoid unwarranted use of strncpy, (continued)
- [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
- Re: [Qemu-devel] [PATCH 11/22] virtio-9p: avoid unwarranted uses of strncpy,
Aneesh Kumar K.V <=
- [Qemu-devel] [PATCH 17/22] libcacard/vcard_emul_nss: use pstrcpy in place of strncpy, Jim Meyering, 2012/05/09
- [Qemu-devel] [PATCH 16/22] qemu-ga: prefer pstrcpy: consistently NUL-terminate ifreq.ifr_name, Jim Meyering, 2012/05/09
- [Qemu-devel] [PATCH 15/22] target-i386: use pstrcpy, not strncpy, Jim Meyering, 2012/05/09
- [Qemu-devel] [PATCH 07/22] ppc: avoid buffer overrun: use pstrcpy, not strncpy, Jim Meyering, 2012/05/09
- [Qemu-devel] [PATCH 02/22] sheepdog: avoid a few buffer overruns, Jim Meyering, 2012/05/09
- [Qemu-devel] [PATCH 14/22] vscsi: avoid unwarranted strncpy, Jim Meyering, 2012/05/09