]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ip: fix format string when reading statistics
authorStephen Hemminger <shemming@brocade.com>
Thu, 10 Dec 2015 16:52:10 +0000 (08:52 -0800)
committerStephen Hemminger <shemming@brocade.com>
Thu, 10 Dec 2015 16:52:10 +0000 (08:52 -0800)
The tunnel code was doing sscanf(buf, "%ld", &x) where x was unsigned
long.

ip/ip6tunnel.c
ip/iptunnel.c

index 320d2539adbfcf5e83a71c48001c4a19bf40e6eb..1737d884319ecb55a8deaca8cf41c532480b1462 100644 (file)
@@ -354,7 +354,7 @@ static int do_tunnels_list(struct ip6_tnl_parm2 *p)
                        fprintf(stderr, "Wrong format for /proc/net/dev. Giving up.\n");
                        goto end;
                }
-               if (sscanf(ptr, "%ld%ld%ld%ld%ld%ld%ld%*d%ld%ld%ld%ld%ld%ld%ld",
+               if (sscanf(ptr, "%lu%lu%lu%lu%lu%lu%lu%*d%lu%lu%lu%lu%lu%lu%lu",
                           &rx_bytes, &rx_packets, &rx_errs, &rx_drops,
                           &rx_fifo, &rx_frame, &rx_multi,
                           &tx_bytes, &tx_packets, &tx_errs, &tx_drops,
index ce9ee3204a8b520e088390b712f3e672c2ba0613..a3ff99bd87eb8c29c8a2003b9a0532f85c2a28b8 100644 (file)
@@ -419,7 +419,7 @@ static int do_tunnels_list(struct ip_tunnel_parm *p)
                        fprintf(stderr, "Wrong format for /proc/net/dev. Giving up.\n");
                        goto end;
                }
-               if (sscanf(ptr, "%ld%ld%ld%ld%ld%ld%ld%*d%ld%ld%ld%ld%ld%ld%ld",
+               if (sscanf(ptr, "%lu%lu%lu%lu%lu%lu%lu%*d%lu%lu%lu%lu%lu%lu%lu",
                           &rx_bytes, &rx_packets, &rx_errs, &rx_drops,
                           &rx_fifo, &rx_frame, &rx_multi,
                           &tx_bytes, &tx_packets, &tx_errs, &tx_drops,