mirror of
https://github.com/stefanberger/swtpm.git
synced 2026-01-08 20:57:37 +00:00
swtpm: Return error if more bytes received than user wanted to send
Some checks are pending
Coverity Scan / coverity (push) Waiting to run
Some checks are pending
Coverity Scan / coverity (push) Waiting to run
Return an error code if HASH_DATA received more bytes from the user than what the user indicated in the length field that he wanted to send. This avoids an integer underrun of the 'remain' variable in the loop that would then cause the loop to wanting to receive around 4GB of data. Also fix some indentation issues. Use be32toh instead of (the equivalent) htobe32 when reading from the packet. Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
parent
4da66c66f9
commit
1db1037525
@ -695,14 +695,16 @@ int ctrlchannel_process_fd(int fd,
|
||||
|
||||
case CMD_HASH_DATA:
|
||||
if (!*tpm_running)
|
||||
goto err_not_running;
|
||||
goto err_not_running;
|
||||
|
||||
if (n < (ssize_t)offsetof(ptm_hdata, u.req.data)) /* rw */
|
||||
goto err_bad_input;
|
||||
goto err_bad_input;
|
||||
|
||||
data = (ptm_hdata *)&input.body;
|
||||
remain = htobe32(data->u.req.length);
|
||||
remain = be32toh(data->u.req.length);
|
||||
n -= sizeof(data->u.req.length);
|
||||
if (remain < n)
|
||||
goto err_bad_input;
|
||||
/* n has the available number of bytes to hash */
|
||||
|
||||
while (true) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user