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 <daniel.trick@sit.fraunhofer.de>
Resolves: https://github.com/stefanberger/libtpms/issues/559
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
Stefan Berger 2026-03-03 10:20:41 -05:00 committed by Stefan Berger
parent 9787502b16
commit 0501a89a29

View File

@ -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;