[gupnp/gupnp-1.0] linux-cm: Avoid unterminated string
- From: Jens Georg <jensgeorg src gnome org>
 
- To: commits-list gnome org
 
- Cc: 
 
- Subject: [gupnp/gupnp-1.0] linux-cm: Avoid unterminated string
 
- Date: Tue, 24 Jul 2018 16:14:50 +0000 (UTC)
 
commit de9b0173ef650ed78690519e5fd6a1ddaed90a03
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Jul 24 12:43:50 2018 +0000
    linux-cm: Avoid unterminated string
    
    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.
    
    
    (cherry picked from commit 85bae723e4ebb90275293697bc3ce95d420774b2)
 libgupnp/gupnp-linux-context-manager.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
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);
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]