]> www.infradead.org Git - users/dwmw2/qemu.git/commit
tpm_emulator: Read control channel response in 2 passes
authorStefan Berger <stefanb@linux.ibm.com>
Wed, 16 Oct 2024 17:51:29 +0000 (13:51 -0400)
committerStefan Berger <stefanb@linux.ibm.com>
Fri, 18 Oct 2024 11:55:08 +0000 (07:55 -0400)
commitd2bcaacc17c4427bdb2d959cd91a42425fcca3c9
tree57d99aae28bb19059cceb50d4fb65898c4627697
parent312c5404011f6a80d1467a19abd916fd203dd7d4
tpm_emulator: Read control channel response in 2 passes

Error responses from swtpm are typically only 4 bytes long with the
exception of a few commands that return more bytes. Therefore, read the
entire response in 2 steps and stop if the first few bytes indicate an
error response with no subsequent bytes readable. Read the rest in a 2nd
step, if needed. This avoids getting stuck while waiting for too many
bytes in case of an error. The 'getting stuck' condition has not been
observed in practice so far, though.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2615
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
backends/tpm/tpm_emulator.c