tpm2: Access entrysize variable only if it was read from buffer (Coverity)

Only access the entrysize variable if it was read from the buffer. In case
of an error just head towards the exit. Previously, an error would also
have lead the function to do no more useful processing and exited it with
an error code bug Coverity complains that the entrysize variable would be
access while it wasn't initialized.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
Stefan Berger 2022-05-28 14:07:28 -04:00 committed by Stefan Berger
parent 4923e9d67a
commit b6b8506bce

View File

@ -4641,7 +4641,8 @@ USER_NVRAM_Unmarshal(BYTE **buffer, INT32 *size)
}
if (rc == TPM_RC_SUCCESS) {
rc = UINT32_Unmarshal(&entrysize, buffer, size);
}
if (rc == TPM_RC_SUCCESS) {
/* the entrysize also depends on the sizeof(nvi); we may have to
update it if sizeof(nvi) changed between versions */
entrysize_offset = o;
@ -4649,9 +4650,8 @@ USER_NVRAM_Unmarshal(BYTE **buffer, INT32 *size)
offset = sizeof(UINT32);
if (entrysize == 0)
break;
}
/* 2nd: handle */
if (rc == TPM_RC_SUCCESS) {
/* 2nd: handle */
rc = TPM_HANDLE_Unmarshal(&handle, buffer, size);
}