]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
bridge: avoid snprint truncation on time
authorStephen Hemminger <stephen@networkplumber.org>
Mon, 19 Mar 2018 16:40:47 +0000 (09:40 -0700)
committerStephen Hemminger <stephen@networkplumber.org>
Thu, 29 Mar 2018 15:30:27 +0000 (08:30 -0700)
This fixes new gcc warning about possible string overflow.

mdb.c: In function ‘__print_router_port_stats’:
mdb.c:61:11: warning: ‘%.2i’ directive output may be truncated
 writing between 2 and 7 bytes into a region of size
 between 0 and 4 [-Wformat-truncation=]
      "%4i.%.2i", (int)tv.tv_sec,
           ^~~~
Note: already fixed in iproute2-next.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
bridge/mdb.c

index 58c20b82b8a63b15a16bb79fceafe085e91cc122..659cac3ff20a171424ae2fded0ac06ea54f6fb6f 100644 (file)
@@ -55,7 +55,7 @@ static void __print_router_port_stats(FILE *f, struct rtattr *pattr)
                __jiffies_to_tv(&tv,
                                rta_getattr_u32(tb[MDBA_ROUTER_PATTR_TIMER]));
                if (jw_global) {
-                       char formatted_time[9];
+                       char formatted_time[32];
 
                        snprintf(formatted_time, sizeof(formatted_time),
                                 "%4i.%.2i", (int)tv.tv_sec,
@@ -184,7 +184,7 @@ static void print_mdb_entry(FILE *f, int ifindex, struct br_mdb_entry *e,
 
                __jiffies_to_tv(&tv, rta_getattr_u32(tb[MDBA_MDB_EATTR_TIMER]));
                if (jw_global) {
-                       char formatted_time[9];
+                       char formatted_time[32];
 
                        snprintf(formatted_time, sizeof(formatted_time),
                                 "%4i.%.2i", (int)tv.tv_sec,