diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2012-04-05 14:03:46 -0400 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2012-04-09 08:21:39 -0400 |
commit | 39ed7bb0c0e1d4c431033b77cdeb176cfeae26e9 (patch) | |
tree | f1b927b83af89149a97058ebd0b52cc9f15f2827 | |
parent | 20cd9a212158ef7ed2200d8746ae96c2feba6651 (diff) | |
download | sssd-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.
-rw-r--r-- | src/monitor/monitor_netlink.c | 3 |
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); |