tpm2: Check valid range of command code before conversion to index

Check the range of the (untrusted) command code before converting it to
a command index.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
Stefan Berger 2026-03-23 17:28:12 -04:00 committed by Stefan Berger
parent de20bf4779
commit cea0585f5c

View File

@ -415,6 +415,8 @@ LIB_EXPORT BOOL
RuntimeCommandsCheckEnabled(struct RuntimeCommands *RuntimeCommands,
TPM_CC cc)
{
if (cc > TPM_CC_LAST || cc < TPM_CC_FIRST)
return FALSE;
return RuntimeCommandsCheckEnabledByIdx(RuntimeCommands, CcToIdx(cc));
}