[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCHv3 15/20] qemu-ga: prefer pstrcpy: consistently NUL-t
From: |
Jim Meyering |
Subject: |
[Qemu-devel] [PATCHv3 15/20] qemu-ga: prefer pstrcpy: consistently NUL-terminate ifreq.ifr_name |
Date: |
Thu, 4 Oct 2012 13:09:58 +0200 |
From: Jim Meyering <address@hidden>
NUL-termination of the .ifr_name field is not required, but is fine
(and preferable to using strncpy and leaving the reader to wonder),
since the first thing the linux kernel does is to clear the last byte.
Besides, using pstrcpy here makes this setting of ifr_name consistent
with the other code (e.g., net/tap-linux.c) that does the same thing.
Reviewed-by: Luiz Capitulino <address@hidden>
Signed-off-by: Jim Meyering <address@hidden>
---
qga/commands-posix.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index ce90421..b9f357c 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -828,7 +828,7 @@ GuestNetworkInterfaceList
*qmp_guest_network_get_interfaces(Error **errp)
}
memset(&ifr, 0, sizeof(ifr));
- strncpy(ifr.ifr_name, info->value->name, IF_NAMESIZE);
+ pstrcpy(ifr.ifr_name, IF_NAMESIZE, info->value->name);
if (ioctl(sock, SIOCGIFHWADDR, &ifr) == -1) {
snprintf(err_msg, sizeof(err_msg),
"failed to get MAC address of %s: %s",
--
1.8.0.rc0.18.gf84667d
- [Qemu-devel] [PATCHv3 04/20] sheepdog: avoid a few buffer overruns, (continued)
- [Qemu-devel] [PATCHv3 04/20] sheepdog: avoid a few buffer overruns, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 07/20] lm32: avoid buffer overrun, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 10/20] linux-user: remove two unchecked uses of strdup, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 08/20] os-posix: avoid buffer overrun, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 09/20] ppc: avoid buffer overrun: use pstrcpy, not strncpy, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 12/20] bt: replace fragile snprintf use and unwarranted strncpy, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 11/20] ui/vnc: simplify and avoid strncpy, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 15/20] qemu-ga: prefer pstrcpy: consistently NUL-terminate ifreq.ifr_name,
Jim Meyering <=
- [Qemu-devel] [PATCHv3 16/20] libcacard/vcard_emul_nss: use pstrcpy in place of strncpy, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 13/20] virtio-9p: avoid unwarranted uses of strncpy, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 14/20] vscsi: avoid unwarranted strncpy, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 20/20] doc: update HACKING wrt strncpy/pstrcpy, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 18/20] qcow2: mark this file's sole strncpy use as justified, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 19/20] hw/r2d: add comment: this strncpy use is ok, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 17/20] acpi: remove strzcpy (strncpy-identical) function; just use strncpy, Jim Meyering, 2012/10/04