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>