]> The Tcpdump Group git mirrors - tcpdump/commitdiff
BGP: Address a -Wformat-truncation= compiler warning
authorFrancois-Xavier Le Bail <[email protected]>
Wed, 27 May 2020 15:28:27 +0000 (17:28 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Wed, 27 May 2020 16:37:14 +0000 (18:37 +0200)
The warning was:
./print-bgp.c:973:79: warning: 'snprintf' output may be truncated before the last format character [-Wformat-truncation=]
  973 |         snprintf(output, sizeof(output), "route-target: %u.%u.%u.%u:%u/%d (%s)",
      |                                                                               ^
./print-bgp.c:973:9: note: 'snprintf' output between 30 and 61 bytes into a destination of size 60
  973 |         snprintf(output, sizeof(output), "route-target: %u.%u.%u.%u:%u/%d (%s)",
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  974 |                  *(pptr+2), *(pptr+3), *(pptr+4), *(pptr+5),
      |                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  975 |                  EXTRACT_BE_U_2(pptr+6), plen, rtc_prefix_in_hex);
      |                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

print-bgp.c

index b3f2ada49ebfb275418b980255c288ef5daec76d..5e9582ce5637e4a752c17226c0247fb2c0865d11 100644 (file)
@@ -924,7 +924,7 @@ bgp_rt_prefix_print(netdissect_options *ndo,
     /* allocate space for the largest possible string */
     char rtc_prefix_in_hex[20] = "";
     u_int rtc_prefix_in_hex_len = 0;
-    static char output[60]; /* max response string */
+    static char output[61]; /* max response string */
     uint16_t ec_type = 0;
     u_int octet_count;
     u_int i;