From 36069716395fbf64d6d455f6efcb0b6fa2ac1e5a Mon Sep 17 00:00:00 2001 From: Stefan Berger Date: Wed, 26 Sep 2018 17:53:30 -0400 Subject: [PATCH] tpm2: Initialize needed_size with 0 gcc 4.2.1 on i386 OpenBSD complains about needed_size being used uninitilized. It seems a false positive but we can still initialize it to 0. Also set t = NULL in the error case to speed up the exit from the loop. Signed-off-by: Stefam Berger --- src/tpm2/NVMarshal.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/tpm2/NVMarshal.c b/src/tpm2/NVMarshal.c index 1bc1e20d..a3b74f10 100644 --- a/src/tpm2/NVMarshal.c +++ b/src/tpm2/NVMarshal.c @@ -805,7 +805,7 @@ PCR_SAVE_Unmarshal(PCR_SAVE *data, BYTE **buffer, INT32 *size, const TPML_PCR_SELECTION *pcrAllocated) { TPM_RC rc = TPM_RC_SUCCESS; - UINT16 array_size, needed_size; + UINT16 array_size, needed_size = 0; NV_HEADER hdr; TPM_ALG_ID algid; BOOL end = FALSE; @@ -873,6 +873,7 @@ PCR_SAVE_Unmarshal(PCR_SAVE *data, BYTE **buffer, INT32 *size, TPMLIB_LogTPM2Error("PCR_SAVE: Unsupported algid %d.", algid); rc = TPM_RC_BAD_PARAMETER; + t = NULL; } } if (t) { @@ -994,7 +995,7 @@ PCR_Unmarshal(PCR *data, BYTE **buffer, INT32 *size, NV_HEADER hdr; BOOL end = FALSE; BYTE *t = NULL; - UINT16 needed_size, array_size; + UINT16 needed_size = 0, array_size; TPM_ALG_ID algid; UINT64 algs_needed = pcrbanks_algs_active(pcrAllocated); @@ -1048,6 +1049,7 @@ PCR_Unmarshal(PCR *data, BYTE **buffer, INT32 *size, TPMLIB_LogTPM2Error("PCR: Unsupported algid %d.", algid); rc = TPM_RC_BAD_PARAMETER; + t = NULL; } } if (t) {