mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-19 03:15:00 +00:00
tpm: Check outgoing command size
In tpm_sendrecv_command() the command buffer is passed in. If a mistake is somehow made in setting this up, the size could be out of range. Add a sanity check for this. Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Coverity (CID: 331152)
This commit is contained in:
parent
4d159b6f84
commit
fdfae3727c
1 changed files with 5 additions and 0 deletions
|
@ -176,6 +176,11 @@ u32 tpm_sendrecv_command(struct udevice *dev, const void *command,
|
||||||
}
|
}
|
||||||
|
|
||||||
size = tpm_command_size(command);
|
size = tpm_command_size(command);
|
||||||
|
|
||||||
|
/* sanity check, which also helps coverity */
|
||||||
|
if (size > COMMAND_BUFFER_SIZE)
|
||||||
|
return log_msg_ret("size", -E2BIG);
|
||||||
|
|
||||||
log_debug("TPM request [size:%d]: ", size);
|
log_debug("TPM request [size:%d]: ", size);
|
||||||
for (i = 0; i < size; i++)
|
for (i = 0; i < size; i++)
|
||||||
log_debug("%02x ", ((u8 *)command)[i]);
|
log_debug("%02x ", ((u8 *)command)[i]);
|
||||||
|
|
Loading…
Add table
Reference in a new issue