pkcs11-spy: fix random crash in print_generic()

Depending on stack state print_generic() could cause crash or spurious garbage
in logs.

Example crash:

*** buffer overflow detected ***: pkcs11test terminated

Signed-off-by: Vesa Jääskeläinen <vesa.jaaskelainen@vaisala.com>
This commit is contained in:
Vesa Jääskeläinen 2021-08-03 19:51:47 +03:00 committed by Jakub Jelen
parent 1991fa24ae
commit 7007eda0ba
1 changed files with 2 additions and 1 deletions

View File

@ -141,7 +141,8 @@ print_generic(FILE *f, CK_LONG type, CK_VOID_PTR value, CK_ULONG size, CK_VOID_P
CK_ULONG i;
if((CK_LONG)size != -1 && value != NULL) {
char hex[16*3+1], ascii[16+1];
char hex[16*3+1] = {0};
char ascii[16+1];
char *hex_ptr = hex, *ascii_ptr = ascii;
int offset = 0;