1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-08 21:18:16 +03:00

lib:util: Fix size of tmp array

lib/util/util.c: In function ‘dump_data_block16’:
lib/util/util.c:503:40: error: ‘%04zX’ directive output may be truncated
writing between 4 and 16 bytes into a region of size 15
[-Werror=format-truncation=]
  503 |         snprintf(tmp, sizeof(tmp), "%s[%04zX]", prefix, idx);
      |                                        ^~~~~

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
This commit is contained in:
Andreas Schneider 2024-04-30 13:01:20 +02:00 committed by Andreas Schneider
parent 6aaab84533
commit 8d5b40296f

View File

@ -495,7 +495,9 @@ static void dump_data_block16(const char *prefix, size_t idx,
void (*cb)(const char *buf, void *private_data),
void *private_data)
{
char tmp[16];
size_t prefix_len = strlen(prefix);
/* 16 (=%04zX) + 2 (=[]) + 1 (='\0') => 19 */
char tmp[prefix_len + 19];
size_t i;
SMB_ASSERT(len <= 16);