lib:socket: fix CID 1350009 - illegal memory accesses (BUFFER_SIZE_WARNING)
authorMichael Adam <obnox@samba.org>
Wed, 3 Feb 2016 10:41:23 +0000 (11:41 +0100)
committerMichael Adam <obnox@samba.org>
Sat, 13 Feb 2016 12:14:13 +0000 (13:14 +0100)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11735

Pair-Programmed-With: Guenther Deschner <gd@samba.org>

Signed-off-by: Michael Adam <obnox@samba.org>
Signed-off-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Uri Simchoni <uri@samba.org>
lib/socket/interfaces.c

index cf094f0b4c56607ce6ab2f6a7fc8505828409a5c..847fa6255ba74e61a1870c2f5be9a5ed92833919 100644 (file)
@@ -140,6 +140,11 @@ static void query_iface_speed_from_name(const char *name, uint64_t *speed)
                return;
        }
 
+       if (strlen(name) >= IF_NAMESIZE) {
+               DBG_ERR("Interface name too long.");
+               goto done;
+       }
+
        strncpy(ifr.ifr_name, name, IF_NAMESIZE);
 
        ifr.ifr_data = (void *)&edata;