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 <stefanb@linux.vnet.ibm.com>
This commit is contained in:
Stefan Berger 2018-09-26 17:53:30 -04:00
parent 7827f8450b
commit 3606971639

View File

@ -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) {