tl-parser icon indicating copy to clipboard operation
tl-parser copied to clipboard

Fix building with gcc7

Open XRevan86 opened this issue 8 years ago • 1 comments

tl-parser.c: In function 'tl_parse_args134':
tl-parser.c:1907:21: error: '__builtin___sprintf_chk' may write a terminating nul past the end of the destination [-Werror=format-overflow=]
         sprintf (s, "%lld", lrand48 () * (1ll << 32) + lrand48 ());
                     ^~~~~~
In file included from /usr/include/stdio.h:939:0,
                 from tl-parser.c:32:
/usr/include/bits/stdio2.h:33:10: note: '__builtin___sprintf_chk' output between 2 and 21 bytes into a destination of size 20
   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       __bos (__s), __fmt, __va_arg_pack ());
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Looks like it tries to count the possible "minus" symbol too. But lrand48() is factually non-negative, so looks reasonable to explicitly write down an unsigned integer.

XRevan86 avatar Jun 12 '17 07:06 XRevan86

Thanks!

korbino avatar Jan 02 '18 00:01 korbino