summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2012-04-05 14:03:46 -0400
committerStephen Gallagher <sgallagh@redhat.com>2012-04-09 08:21:29 -0400
commit0fc5c8d9424a2373ef0aa7ebdec337b01a5f55c9 (patch)
treef44907e5b4b47f869be94bb502c32fc635f09e06
parent7e54b96b3e5ef68af9d5d4c81507752a5c259ea8 (diff)
downloadsssd-0fc5c8d9424a2373ef0aa7ebdec337b01a5f55c9.tar.gz
sssd-0fc5c8d9424a2373ef0aa7ebdec337b01a5f55c9.tar.xz
sssd-0fc5c8d9424a2373ef0aa7ebdec337b01a5f55c9.zip
netlink integration: ensure that interface name is NULL-terminated
In the unlikely case that the interface name was IFNAMSIZ bytes long or longer, strncpy wouldn't NULL-terminate the buffer. Copy one byte less to ensure the buffer is NULL-terminated.
-rw-r--r--src/monitor/monitor_netlink.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/monitor/monitor_netlink.c b/src/monitor/monitor_netlink.c
index 8455f6889..2fe380ac9 100644
--- a/src/monitor/monitor_netlink.c
+++ b/src/monitor/monitor_netlink.c
@@ -117,7 +117,8 @@ static bool has_wireless_extension(const char *ifname)
return false;
}
- strncpy(iwr.ifr_ifrn.ifrn_name, ifname, IFNAMSIZ);
+ strncpy(iwr.ifr_ifrn.ifrn_name, ifname, IFNAMSIZ-1);
+ iwr.ifr_ifrn.ifrn_name[IFNAMSIZ-1] = '\0';
/* Does the interface support a wireless extension? */
ret = ioctl(s, SIOCGIWNAME, &iwr);
close(s);