tcpdump mailing list archives
Re: if anyone wanted to practice fixing compiler warnings in tcpdump...
From: Guy Harris <gharris () sonic net>
Date: Sun, 29 Jul 2018 19:20:18 -0700
On Jul 29, 2018, at 5:48 AM, Denis Ovsienko <denis () ovsienko info> wrote:
./util-print.c: In function ‘ts_format.isra.0’: ./util-print.c:265:27: warning: ‘%06u’ directive output may be truncated writing between 6 and 10 bytes into a region of size between 5 and 12 [-Wformat-truncation=] format = "%02d:%02d:%02d.%06u"; ^~~~ ./util-print.c:265:11: note: using the range [0, 4294967295] for directive argument format = "%02d:%02d:%02d.%06u"; ^~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/stdio.h:862:0, from ./util-print.c:50: /usr/include/x86_64-linux-gnu/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’ output between 16 and 27 bytes into a destination of size 21 return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ __bos (__s), __fmt, __va_arg_pack ()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Not formatting to a buffer, but directly printing with ND_PRINT(), should squelch this annoyance; yeah, if the time stamp is in seconds/microseconds, and the microseconds value is >= 10^6, something might not be formatted correctly, but that's life. Done in 230e0b85778df66f9cec62d13f0025c78cc0c9da. I guess we *could* do range checking and print some warning that it's bogus; I'll leave that as an exercise to the reader. (Don't forget to do it for nanosecond-resolution time stamps, too, as 2^32-1 and even 2^31-1 is > 10^9.) _______________________________________________ tcpdump-workers mailing list tcpdump-workers () lists tcpdump org https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers
Current thread:
- if anyone wanted to practice fixing compiler warnings in tcpdump... Denis Ovsienko (Jul 29)
- Re: if anyone wanted to practice fixing compiler warnings in tcpdump... Guy Harris (Jul 29)
- Re: if anyone wanted to practice fixing compiler warnings in tcpdump... Denis Ovsienko (Jul 30)
- Re: if anyone wanted to practice fixing compiler warnings in tcpdump... Guy Harris (Jul 29)
- Re: if anyone wanted to practice fixing compiler warnings in tcpdump... Guy Harris (Jul 29)