[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 13/22] virtio-9p: avoid unwarranted use of strncpy
From: |
Jim Meyering |
Subject: |
[Qemu-devel] [PATCH 13/22] virtio-9p: avoid unwarranted use of strncpy |
Date: |
Wed, 9 May 2012 11:23:57 +0200 |
From: Jim Meyering <address@hidden>
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 <address@hidden>
---
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
- Re: [Qemu-devel] [PATCH 08/22] linux-user: remove two unchecked uses of strdup, (continued)
- Re: [Qemu-devel] [PATCH 08/22] linux-user: remove two unchecked uses of strdup, Peter Maydell, 2012/05/09
- Re: [Qemu-devel] [PATCH 08/22] linux-user: remove two unchecked uses of strdup, Jim Meyering, 2012/05/09
- Re: [Qemu-devel] [PATCH 08/22] linux-user: remove two unchecked uses of strdup, Peter Maydell, 2012/05/09
- Re: [Qemu-devel] [PATCH 08/22] linux-user: remove two unchecked uses of strdup, Jim Meyering, 2012/05/09
- Re: [Qemu-devel] [PATCH 08/22] linux-user: remove two unchecked uses of strdup, Peter Maydell, 2012/05/09
- Re: [Qemu-devel] [PATCH 08/22] linux-user: remove two unchecked uses of strdup, Jim Meyering, 2012/05/09
[Qemu-devel] [PATCH 03/22] vmdk: relative_path: avoid buffer overrun, Jim Meyering, 2012/05/09
[Qemu-devel] [PATCH 13/22] virtio-9p: avoid unwarranted use of strncpy,
Jim Meyering <=
[Qemu-devel] [PATCH 05/22] lm32: avoid buffer overrun, Jim Meyering, 2012/05/09
[Qemu-devel] [PATCH 19/22] qcow2: mark this file's sole strncpy use as justified, Jim Meyering, 2012/05/09
[Qemu-devel] [PATCH 21/22] scsi: mark an strncpy use as valid, Jim Meyering, 2012/05/09
Re: [Qemu-devel] strncpy: best avoided (resend), Kevin Wolf, 2012/05/10