From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:34413) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SS38B-00063B-Kk for qemu-devel@nongnu.org; Wed, 09 May 2012 05:24:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SS384-00029D-IX for qemu-devel@nongnu.org; Wed, 09 May 2012 05:24:23 -0400 Received: from mx.meyering.net ([88.168.87.75]:36942) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SS384-00025C-Bn for qemu-devel@nongnu.org; Wed, 09 May 2012 05:24:16 -0400 From: Jim Meyering Date: Wed, 9 May 2012 11:23:57 +0200 Message-Id: <1336555446-20180-14-git-send-email-jim@meyering.net> In-Reply-To: <1336555446-20180-1-git-send-email-jim@meyering.net> References: <1336555446-20180-1-git-send-email-jim@meyering.net> Subject: [Qemu-devel] [PATCH 13/22] virtio-9p: avoid unwarranted use of strncpy List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Jim Meyering , "Aneesh Kumar K.V" From: Jim Meyering The use of strncpy in pt_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 --- hw/9pfs/virtio-9p-xattr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/9pfs/virtio-9p-xattr.c b/hw/9pfs/virtio-9p-xattr.c index 7f08f6e..a839606 100644 --- a/hw/9pfs/virtio-9p-xattr.c +++ b/hw/9pfs/virtio-9p-xattr.c @@ -53,7 +53,8 @@ ssize_t pt_listxattr(FsContext *ctx, const char *path, return -1; } - strncpy(value, name, name_size); + /* no need for strncpy: name_size is strlen(name)+1 */ + memcpy(value, name, name_size); return name_size; } -- 1.7.10.1.487.ga3935e6