]> git.itanic.dy.fi Git - rrdd/commit
Silence gcc-8 snprintf overflow warnings
authorTimo Kokkonen <timo.t.kokkonen@iki.fi>
Fri, 7 Sep 2018 18:16:27 +0000 (21:16 +0300)
committerTimo Kokkonen <timo.t.kokkonen@iki.fi>
Fri, 7 Sep 2018 18:21:14 +0000 (21:21 +0300)
commit5c4ca53b276c6670da6e143ef4b161e1f91cf205
tree9434f11d870c84de2bc0db25472bd83ac0176056
parentd78c739152d9b656908423a41c6c9f119e47fc44
Silence gcc-8 snprintf overflow warnings

When compilint with gcc-8 and newer, we get warnings like:

/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’ output between 11 and 2057 bytes into a destination of size 1024
   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        __bos (__s), __fmt, __va_arg_pack ());
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This is because gcc thinks (correctly) that it is possible for the
resulting string to be larger than the buffer we ask snprintf to print
it. This is pretty bening warning, as we are not expecting to see this
kind of situations ever.

To work around the warning, add an error print for such cases when
actual overflow takes place. No actual memory overflow takes place
however as snprintf prevents this. But this also makes gcc happy as we
are now dealing the error case.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
built_in_parsers.c
onewire_parser.c