qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 12/22] virtio-9p: avoid unwarranted use of strncpy


From: Jim Meyering
Subject: [Qemu-devel] [PATCH 12/22] virtio-9p: avoid unwarranted use of strncpy
Date: Wed, 9 May 2012 11:23:56 +0200

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>
---
 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




reply via email to

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