summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2018-07-24 14:43:50 +0200
committerBastien Nocera <hadess@hadess.net>2018-07-24 14:43:50 +0200
commit85bae723e4ebb90275293697bc3ce95d420774b2 (patch)
tree8f0ec92589f35c80dffb3a3ba2944fe047bc9620
parent1495d0d7615caa6ad0d6a94108d414915a55c414 (diff)
downloadgupnp-wip/hadess/defects.tar.gz
linux-cm: Avoid unterminated stringwip/hadess/defects
If the wireless card's name is exactly IFNAMSIZ bytes long (without the terminating NUL), then iwr.ifr_name will lack the terminating NUL character. Only copy IFNAMSIZ - 1 bytes so we can be sure that the last character will terminate the string properly.
-rw-r--r--libgupnp/gupnp-linux-context-manager.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libgupnp/gupnp-linux-context-manager.c b/libgupnp/gupnp-linux-context-manager.c
index 9ec0491..90fb56d 100644
--- a/libgupnp/gupnp-linux-context-manager.c
+++ b/libgupnp/gupnp-linux-context-manager.c
@@ -233,7 +233,7 @@ network_device_update_essid (NetworkInterface *device)
/* Query essid */
memset (&iwr, 0, sizeof (struct iwreq));
memset (essid, 0, IW_ESSID_MAX_SIZE + 1);
- strncpy (iwr.ifr_name, device->name, IFNAMSIZ);
+ strncpy (iwr.ifr_name, device->name, IFNAMSIZ - 1);
iwr.u.essid.pointer = (caddr_t) essid;
iwr.u.essid.length = IW_ESSID_MAX_SIZE;
ret = ioctl (device->manager->priv->fd, SIOCGIWESSID, &iwr);