ifnet: ensure string termination
authorFerry Huberts <ferry.huberts@pelagic.nl>
Wed, 17 Feb 2016 17:58:44 +0000 (18:58 +0100)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Wed, 17 Feb 2016 17:58:58 +0000 (18:58 +0100)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
src/unix/ifnet.c

index 447ab6e..154b92c 100644 (file)
@@ -860,6 +860,7 @@ LinkState getInterfaceLinkState(const char * iface) {
 
   edata.cmd = ETHTOOL_GLINK;
   strncpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name));
+  ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0'; /* ensure string termination */
   ifr.ifr_data = (caddr_t) &edata;
   errno = 0;
   if (!ioctl(fd, SIOCETHTOOL, &ifr)) {