qemu-devel
[Top][All Lists]
Advanced

[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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]