]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
ip: fix igmp parsing when iface is long
authorPetr Vorel <pvorel@suse.cz>
Mon, 16 Jan 2017 23:25:50 +0000 (00:25 +0100)
committerStephen Hemminger <stephen@networkplumber.org>
Tue, 17 Jan 2017 16:39:55 +0000 (08:39 -0800)
Entries with long vhost names in /proc/net/igmp have no whitespace
between name and colon, so sscanf() adds it to vhost and
'ip maddr show iface' doesn't include inet result.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
ip/ipmaddr.c

index 22eb407b4d98cb9b82385ce22d172d41c9859dd3..4f726fdd976f1363b4392c3d7008b61d9a68c7ca 100644 (file)
@@ -136,13 +136,17 @@ static void read_igmp(struct ma_info **result_p)
 
        while (fgets(buf, sizeof(buf), fp)) {
                struct ma_info *ma;
+               size_t len;
 
                if (buf[0] != '\t') {
                        sscanf(buf, "%d%s", &m.index, m.name);
+                       len = strlen(m.name);
+                       if (m.name[len - 1] == ':')
+                               len--;
                        continue;
                }
 
-               if (filter.dev && strcmp(filter.dev, m.name))
+               if (filter.dev && strncmp(filter.dev, m.name, len))
                        continue;
 
                sscanf(buf, "%08x%d", (__u32 *)&m.addr.data, &m.users);