diff mbox series

[08/11] util/vhost-user-server: check EOF when reading payload

Message ID 20200922160401.294055-9-stefanha@redhat.com
State Accepted
Commit edaf6205a3a58e09bf31b7ebd73d8fc470e96e07
Headers show
Series block/export: convert vhost-user-blk-server to block exports API | expand

Commit Message

Stefan Hajnoczi Sept. 22, 2020, 4:03 p.m. UTC
Unexpected EOF is an error that must be reported.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 util/vhost-user-server.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/util/vhost-user-server.c b/util/vhost-user-server.c
index 5a60e2ca2a..ec555abcb2 100644
--- a/util/vhost-user-server.c
+++ b/util/vhost-user-server.c
@@ -169,8 +169,10 @@  vu_message_read(VuDev *vu_dev, int conn_fd, VhostUserMsg *vmsg)
     };
     if (vmsg->size) {
         rc = qio_channel_readv_all_eof(ioc, &iov_payload, 1, &local_err);
-        if (rc == -1) {
-            error_report_err(local_err);
+        if (rc != 1) {
+            if (local_err) {
+                error_report_err(local_err);
+            }
             goto fail;
         }
     }