tpm2: Extend buffer for printing a UINT16 into to 12 bytes (older gcc)

Even though UINT16 when printed as hex number will only use up to 4 bytes
and 3 more bytes for the prefix '0x' and terminating NUL (0xffff), extend
the buffer to 16 bytes to address the following gcc issue:

tpm2/RuntimeCommands.c:450:44: error: ‘__builtin___snprintf_chk’ output
   may be truncated before the last format character
   [-Werror=format-truncation=]

  snprintf(bufferhi, sizeof(bufferhi), "0x%x", commandCodeHi);

/usr/include/x86_64-linux-gnu/bits/stdio2.h:64:10: note:
   ‘__builtin___snprintf_chk’ output between 4 and 11 bytes into a
   destination of size 10

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
Stefan Berger 2024-07-17 23:22:03 -04:00 committed by Stefan Berger
parent 92ab421194
commit fe69c3d4b1

View File

@ -435,8 +435,7 @@ RuntimeCommandPrint(char *buffer,
COMMAND_INDEX commandCodeLo,
COMMAND_INDEX commandCodeHi)
{
MUST_BE(sizeof(COMMAND_INDEX) == 2);
char bufferlo[10], bufferhi[10];
char bufferlo[12], bufferhi[12];
char *nbuffer = NULL;
int n;