diff options
author | Jim Meyering <meyering@redhat.com> | 2012-10-04 13:09:58 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2012-10-05 07:58:37 -0500 |
commit | 1ab516ed9b6ba00bafc5ca37604f8af4680323ca (patch) | |
tree | 9063a855e9145c078cf2056c96a33167fc8be086 /qga/commands-posix.c | |
parent | 9d055d8ac83cfd590263e8862ff683f705dfdf56 (diff) | |
download | qemu-1ab516ed9b6ba00bafc5ca37604f8af4680323ca.tar.gz qemu-1ab516ed9b6ba00bafc5ca37604f8af4680323ca.tar.bz2 qemu-1ab516ed9b6ba00bafc5ca37604f8af4680323ca.zip |
qemu-ga: prefer pstrcpy: consistently NUL-terminate ifreq.ifr_name
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 <lcapitulino@redhat.com>
Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'qga/commands-posix.c')
-rw-r--r-- | qga/commands-posix.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/qga/commands-posix.c b/qga/commands-posix.c index ce9042123c..b9f357cb96 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", |