9pfs: proxy: assert if unmarshal fails
commit262169abe74b4c2d8b299b7499904cfc3c1902ea
authorGreg Kurz <groug@kaod.org>
Tue, 21 Mar 2017 08:12:47 +0000 (21 09:12 +0100)
committerGreg Kurz <groug@kaod.org>
Tue, 21 Mar 2017 08:12:47 +0000 (21 09:12 +0100)
tree2194b2c74236074d6b345ee39f0f176782cfb07e
parentd5f2af7b95b738b25272a98319b09540a0606d14
9pfs: proxy: assert if unmarshal fails

Replies from the virtfs proxy are made up of a fixed-size header (8 bytes)
and a payload of variable size (maximum 64kb). When receiving a reply,
the proxy backend first reads the whole header and then unmarshals it.
If the header is okay, it then does the same operation with the payload.

Since the proxy backend uses a pre-allocated buffer which has enough room
for a header and the maximum payload size, marshalling should never fail
with fixed size arguments. Any error here is likely to result from a more
serious corruption in QEMU and we'd better dump core right away.

This patch adds error checks where they are missing and converts the
associated error paths into assertions.

This should also address Coverity's complaints CID 1348519 and CID 1348520,
about not always checking the return value of proxy_unmarshal().

Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
hw/9pfs/9p-proxy.c