From cea0585f5c5d64e3f543aeededd9b21d6334bb9e Mon Sep 17 00:00:00 2001 From: Stefan Berger Date: Mon, 23 Mar 2026 17:28:12 -0400 Subject: [PATCH] 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 --- src/tpm2/RuntimeCommands.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tpm2/RuntimeCommands.c b/src/tpm2/RuntimeCommands.c index 7af67fe6..4752b31d 100644 --- a/src/tpm2/RuntimeCommands.c +++ b/src/tpm2/RuntimeCommands.c @@ -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)); }