From 0d0354463ee36132e76c78e5ef10a6f08f641bfa Mon Sep 17 00:00:00 2001 From: Marc Gonzalez Date: Wed, 19 Jul 2023 12:52:16 +0200 Subject: [PATCH] libdisasm: Widen STRNCATF temp buffer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/third_party/libdisasm/x86_format.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/third_party/libdisasm/x86_format.c b/src/third_party/libdisasm/x86_format.c index 0ec960dc..bb547ad4 100644 --- a/src/third_party/libdisasm/x86_format.c +++ b/src/third_party/libdisasm/x86_format.c @@ -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 ); \