summaryrefslogtreecommitdiff
path: root/src/monitor
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:39 -0400
commit39ed7bb0c0e1d4c431033b77cdeb176cfeae26e9 (patch)
treef1b927b83af89149a97058ebd0b52cc9f15f2827 /src/monitor
parent20cd9a212158ef7ed2200d8746ae96c2feba6651 (diff)
downloadsssd-39ed7bb0c0e1d4c431033b77cdeb176cfeae26e9.tar.gz
sssd-39ed7bb0c0e1d4c431033b77cdeb176cfeae26e9.tar.bz2
sssd-39ed7bb0c0e1d4c431033b77cdeb176cfeae26e9.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.
Diffstat (limited to 'src/monitor')
-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 8455f688..2fe380ac 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);