tpm2: Surround all occurrences of BLOCK_SKIP_READ() with tests of 'rc'

Do not call BLOCK_SKIP_READ once rc has been set to any error value.
Therefore, surround all occurrences of BLOCK_SKIP_READ() with tests
of 'rc'.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
Stefan Berger 2021-05-04 11:37:29 -04:00 committed by Stefan Berger
parent fd5bd3fb1d
commit 0ebbf1e0bb

View File

@ -3485,16 +3485,20 @@ skip_hardware_clock:
if (rc == TPM_RC_SUCCESS && hdr.version >= 2) {
BLOCK_SKIP_READ(skip_future_versions, hdr.version >= 3, buffer, size,
"Volatile State", "version 3 or later");
rc = VolatileState_TailV3_Unmarshal(buffer, size);
BLOCK_SKIP_READ(skip_future_versions, hdr.version >= 4, buffer, size,
"Volatile State", "version 4 or later");
if (rc == TPM_RC_SUCCESS) {
rc = VolatileState_TailV3_Unmarshal(buffer, size);
}
if (rc == TPM_RC_SUCCESS) {
BLOCK_SKIP_READ(skip_future_versions, hdr.version >= 4, buffer, size,
"Volatile State", "version 4 or later");
}
if (rc == TPM_RC_SUCCESS) {
rc = VolatileState_TailV4_Unmarshal(buffer, size);
}
BLOCK_SKIP_READ(skip_future_versions, FALSE, buffer, size,
"Volatile State", "version 5 or later");
if (rc == TPM_RC_SUCCESS) {
BLOCK_SKIP_READ(skip_future_versions, FALSE, buffer, size,
"Volatile State", "version 5 or later");
}
/* future versions append here */
}
@ -4048,10 +4052,14 @@ skip_num_policy_pcr_group:
if (rc == TPM_RC_SUCCESS && hdr.version >= 2) {
BLOCK_SKIP_READ(skip_future_versions, hdr.version >= 3, buffer, size,
"PERSISTENT_DATA", "version 3 or later");
rc = TPML_PCR_SELECTION_Unmarshal(&shadow.pcrAllocated, buffer, size);
if (rc == TPM_RC_SUCCESS) {
rc = TPML_PCR_SELECTION_Unmarshal(&shadow.pcrAllocated, buffer, size);
}
BLOCK_SKIP_READ(skip_future_versions, FALSE, buffer, size,
"PERSISTENT_DATA", "version 4 or later");
if (rc == TPM_RC_SUCCESS) {
BLOCK_SKIP_READ(skip_future_versions, FALSE, buffer, size,
"PERSISTENT_DATA", "version 4 or later");
}
/* future versions nest-append here */
}