tpm2: Initialize variable reported by Coverity (false positive)

Initialize a variable in USER_NVRAM_Unmarshal() follow Coverity
report CID 1470812.

Down the callpath as reported in CID 1470812 in TPMA_NV_Unmarshal() the
passed-in value of TPMA_NV *target is stored and possibly restored later
on in case of failure. Coverity complains that the variable is
uninitialized. While this is correct, there's no harm reading the
uninitialized value from the structure and possibly restoring it later
on while not doing anything else with it otherwise. Therefore, it's a
false positive.

Resolves: https://github.com/stefanberger/libtpms/issues/310
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
Stefan Berger 2022-03-31 10:23:31 -04:00
parent 8590849b65
commit ec873cf8a2

View File

@ -4613,7 +4613,9 @@ USER_NVRAM_Unmarshal(BYTE **buffer, INT32 *size)
NV_REF entryRef = NV_USER_DYNAMIC;
UINT32 entrysize;
UINT64 offset, o = 0;
NV_INDEX nvi;
NV_INDEX nvi = {
.publicArea.attributes = 0, // Coverity
};
UINT64 maxCount;
TPM_HANDLE handle;
OBJECT obj;