From 654ae881de57467642c8c2ed16ffc3a8d57fafa2 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Thu, 10 Dec 2015 08:52:10 -0800 Subject: [PATCH] ip: fix format string when reading statistics The tunnel code was doing sscanf(buf, "%ld", &x) where x was unsigned long. --- ip/ip6tunnel.c | 2 +- ip/iptunnel.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ip/ip6tunnel.c b/ip/ip6tunnel.c index 320d2539a..1737d8843 100644 --- a/ip/ip6tunnel.c +++ b/ip/ip6tunnel.c @@ -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, diff --git a/ip/iptunnel.c b/ip/iptunnel.c index ce9ee3204..a3ff99bd8 100644 --- a/ip/iptunnel.c +++ b/ip/iptunnel.c @@ -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, -- 2.47.2