From 0501a89a2986cf6d02b3d5b512b2d77c0b3c8595 Mon Sep 17 00:00:00 2001 From: Stefan Berger Date: Tue, 3 Mar 2026 10:20:41 -0500 Subject: [PATCH] tpm2: Deactivate bufferSize <= 0 check that prevents bufferSize == 0 (#559) The check covering bufferSize == 0 causes a compatibility issue as described in #559 where a valid command is passed. Also, bufferSize should never be <0 since the preceeding UINT16_Unmarshal() would check whether sufficient bytes are available for unmarshalling and would return an error code if this was not the case. Otherwise it would return TPM_RC_SUCCESS along with the unmarshalled value. The bufferSize would then only be 0 (as lowest possible value) in the success case. Reported-by: Daniel Trick Resolves: https://github.com/stefanberger/libtpms/issues/559 Signed-off-by: Stefan Berger --- src/tpm2/TPMCmd/tpm/src/crypt/CryptUtil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tpm2/TPMCmd/tpm/src/crypt/CryptUtil.c b/src/tpm2/TPMCmd/tpm/src/crypt/CryptUtil.c index 7401f26f..f28773b2 100644 --- a/src/tpm2/TPMCmd/tpm/src/crypt/CryptUtil.c +++ b/src/tpm2/TPMCmd/tpm/src/crypt/CryptUtil.c @@ -994,7 +994,7 @@ CryptParameterDecryption( return TPM_RC_INSUFFICIENT; } - if(cipherSize > MAX_COMMAND_SIZE || bufferSize <= 0 + if(cipherSize > MAX_COMMAND_SIZE /* || bufferSize <= 0 */ // libtpms: deactivate bad check (issue #559) || (UINT32)cipherSize > (UINT32)bufferSize) { return TPM_RC_SIZE;