]> The Tcpdump Group git mirrors - tcpdump/commit
HNCP: refine snprintf() buffers sizing
authorDenis Ovsienko <[email protected]>
Thu, 20 Jul 2017 19:58:06 +0000 (20:58 +0100)
committerDenis Ovsienko <[email protected]>
Thu, 20 Jul 2017 20:04:56 +0000 (21:04 +0100)
commit11fcafcf6928d793411ae3dba9af324e3d027bb2
tree4d38b7169bba02de49d786629e22bddc729d2677
parentd72adb9406a34998a96d148fa701cd4fb573e8b9
HNCP: refine snprintf() buffers sizing

This squelches a warning in format_256(), make a similar change to
format_nid() while at it.

$ gcc --version
gcc (GCC) 7.1.1 20170622 (Red Hat 7.1.1-3)

./print-hncp.c: In function ‘format_256’:
./print-hncp.c:175:26: warning: ‘%016lx’ directive output truncated writing 16 bytes into a region of size 12 [-Wformat-truncation=]
     snprintf(buf[i], 28, "%016" PRIx64 "%016" PRIx64 "%016" PRIx64 "%016" PRIx64,
                          ^~~~~~
./print-hncp.c:175:41: note: format string is defined here
     snprintf(buf[i], 28, "%016" PRIx64 "%016" PRIx64 "%016" PRIx64 "%016" PRIx64,
./print-hncp.c:175:26: note: using the range [0, 18446744073709551615] for directive argument
     snprintf(buf[i], 28, "%016" PRIx64 "%016" PRIx64 "%016" PRIx64 "%016" PRIx64,
                          ^~~~~~
./print-hncp.c:175:26: note: using the range [0, 18446744073709551615] for directive argument
./print-hncp.c:175:26: note: using the range [0, 18446744073709551615] for directive argument
./print-hncp.c:175:5: note: ‘snprintf’ output 65 bytes into a destination of size 28
     snprintf(buf[i], 28, "%016" PRIx64 "%016" PRIx64 "%016" PRIx64 "%016" PRIx64,
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          EXTRACT_64BITS(data),
          ~~~~~~~~~~~~~~~~~~~~~
          EXTRACT_64BITS(data + 8),
          ~~~~~~~~~~~~~~~~~~~~~~~~~
          EXTRACT_64BITS(data + 16),
          ~~~~~~~~~~~~~~~~~~~~~~~~~~
          EXTRACT_64BITS(data + 24)
          ~~~~~~~~~~~~~~~~~~~~~~~~~
     );
     ~
print-hncp.c