libdisasm: Widen STRNCATF temp buffer

The _tmp buffer used in STRNCATF is too small for several callers,
which might lead to truncated output in some situations.

For example, GCC 11 warns:

src/third_party/libdisasm/x86_format.c:899:40: warning: ‘%s’ directive output may be truncated writing up to 63 bytes into a region of size 32 [-Wformat-truncation=]
  899 |                         STRNCATF( buf, "%s:", str, len );
      |                                        ^~~~~  ~~~
src/third_party/libdisasm/x86_format.c:34:38: note: in definition of macro ‘STRNCATF’
   34 |         snprintf( _tmp, sizeof _tmp, fmt, data );   \
      |                                      ^~~
src/third_party/libdisasm/x86_format.c:899:41: note: format string is defined here
  899 |                         STRNCATF( buf, "%s:", str, len );
      |                                         ^~
In file included from /usr/include/stdio.h:894,
                 from src/third_party/libdisasm/x86_format.c:1:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:71:10: note: ‘__builtin___snprintf_chk’ output between 2 and 65 bytes into a destination of size 32
   71 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   72 |                                    __glibc_objsize (__s), __fmt,
      |                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   73 |                                    __va_arg_pack ());
      |                                    ~~~~~~~~~~~~~~~~~

Change-Id: Ia876e288bf9629f2c72db3faf2287c7940924ea0
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/4668735
Reviewed-by: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
Marc Gonzalez 2023-07-19 12:52:16 +02:00 committed by Mike Frysinger
parent 9ea5b228f5
commit 0d0354463e

View file

@ -29,7 +29,7 @@
} while( 0 )
#define STRNCATF( buf, fmt, data, len ) do { \
char _tmp[MAX_OP_STRING]; \
char _tmp[MAX_OP_XML_STRING]; \
\
snprintf( _tmp, sizeof _tmp, fmt, data ); \
STRNCAT( buf, _tmp, len ); \