Split-out those TPM 2 command functions that need to be adapted due to the
functions they call returning an error code. Split them out into their own
files so they can be synchronized easier.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Split-out those TPM 2 command functions that need to be adapted due to the
functions they call returning an error code. Split them out into their own
files so they can be synchronized easier.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Resolve only white space changes on a previously applied patch resolving a
CVE where my version looked slightly different.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Remove the TABLE_DRIVEN_DISPATCH build switch that was set to 'YES'.
Remove code that assumed it to be set to 'NO'.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Upstream has gotten rid of the IS_IMPLEMENTED flag but upstream is also
using compressed lists where each element in the command lists represents
an implemented command. Libtpms does not use compressed lists but we may
have a list with gaps in it due to unimplemented commands where this flag
may be the only one set and help identify an implemented command. However,
since profiles indicate enablement and implementation of commands, and
nearly all tests for the IS_IMPLEMENTED flag are paired with a check on
the profile with RuntimeCommandsCheckEnabled(), we can get rid of tests for
IS_IMPLEMENTED and finally the flag altogether since it is redundant.
Also get rid of NOT_IMPLEMENTED flag that was not used anywhere.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Check that the object returned from HandleToObject is not NULL before
dereferencing it. In practice, this cannot currently happen in the call
paths that GetHierachy() is called because the object described by the
handle is known to exist.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Resolve the following issues detected by gcc's -fanalyzer:
tpm12/tpm_nvram.c: In function 'TPM_Process_NVDefineSpace':
tpm12/tpm_nvram.c:2908:20: warning: dereference of NULL 'd1_new' [CWE-476] [-Wanalyzer-null-dereference]
2908 | newNVIndex = pubInfo->nvIndex; /* save the possibly new index */
| ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Resolve the following issues detected by gcc's -fanalyzer:
tpm12/tpm_counter.c: In function 'TPM_CounterValue_StorePublic.part.0':
tpm12/tpm_counter.c:421:61: warning: dereference of NULL 'tpm_counter_value' [CWE-476] [-Wanalyzer-null-dereference]
421 | rc = TPM_Sbuffer_Append32(sbuffer, tpm_counter_value->counter);
| ~~~~~~~~~~~~~~~~~^~~~~~~~~
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Resolve the following issues detected by gcc's -fanalyzer:
tpm12/tpm_session.c: In function 'TPM_AuthSessionData_Store':
tpm12/tpm_session.c:187:65: warning: dereference of NULL 'tpm_auth_session_data' [CWE-476] [-Wanalyzer-null-dereference]
187 | rc = TPM_Sbuffer_Append32(sbuffer, tpm_auth_session_data->handle);
tpm12/tpm_session.c: In function 'TPM_Process_SaveContext':
tpm12/tpm_session.c:3197:41: warning: use of uninitialized value 'tpm_key_handle_entry' [CWE-457] [-Wanalyzer-use-of-uninitialized-value]
3197 | if (tpm_key_handle_entry->keyControl & TPM_KEY_CONTROL_OWNER_EVICT) {
tpm12/tpm_session.c:3230:26: warning: use of uninitialized value 'tpm_key_handle_entry' [CWE-457] [-Wanalyzer-use-of-uninitialized-value]
3230 | returnCode = TPM_KeyHandleEntry_Store(&r1ContextSensitive, tpm_key_handle_entry);
tpm12/tpm_session.c:3236:26: warning: use of uninitialized value 'tpm_transport_internal' [CWE-457] [-Wanalyzer-use-of-uninitialized-value]
3236 | returnCode = TPM_TransportInternal_Store(&r1ContextSensitive, tpm_transport_internal);
tpm12/tpm_session.c:3239:26: warning: use of uninitialized value 'tpm_daa_session_data' [CWE-457] [-Wanalyzer-use-of-uninitialized-value]
3239 | returnCode = TPM_DaaSessionData_Store(&r1ContextSensitive, tpm_daa_session_data);
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Resolve the following gcc -fanalyzer issue by initializing the variable.
tpm12/tpm_migration.c: In function 'TPM_Process_CMK_CreateBlob':
tpm12/tpm_migration.c:3389:10: warning: use of uninitialized value
'continueAuthSession' [CWE-457] [-Wanalyzer-use-of-uninitialized-value]
3389 | !continueAuthSession) &&
| ^~~~~~~~~~~~~~~~~~~~
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Resolve the following gcc -fanalyzer issue by casting the result of
sizeof() to uint32_t.
tpm12/tpm_cryptoh.c:977:16: warning: 'va_arg' expected 'uint32_t' \
{aka 'unsigned int'} but received 'long unsigned int' \
for variadic argument 3 of 'ap' [CWE-686] [-Wanalyzer-va-arg-type-mismatch]
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
gcc's -fanalyzer claims that strtoul() may be called with str == NULL.
However, this cannot happen since in this case retVal would have been set
from the call to RuntimeProfileGetFromJSON(). In case of error returned
from RuntimeProfileGetFromJSON() we would not get to call strtoul(). So
this is a false-positive.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>