]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
net: ignore packet size greater than INT_MAX
authorJason Wang <jasowang@redhat.com>
Wed, 30 May 2018 05:16:36 +0000 (13:16 +0800)
committerJason Wang <jasowang@redhat.com>
Fri, 19 Oct 2018 03:15:04 +0000 (11:15 +0800)
There should not be a reason for passing a packet size greater than
INT_MAX. It's usually a hint of bug somewhere, so ignore packet size
greater than INT_MAX in qemu_deliver_packet_iov()

CC: qemu-stable@nongnu.org
Reported-by: Daniel Shapira <daniel@twistlock.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
net/net.c

index c66847ed7677304690e6a5e279421ee96a399f5c..07c194a8f60304fd2af5f64e30cb6750d7818ad3 100644 (file)
--- a/net/net.c
+++ b/net/net.c
@@ -712,10 +712,15 @@ ssize_t qemu_deliver_packet_iov(NetClientState *sender,
                                 void *opaque)
 {
     NetClientState *nc = opaque;
+    size_t size = iov_size(iov, iovcnt);
     int ret;
 
+    if (size > INT_MAX) {
+        return size;
+    }
+
     if (nc->link_down) {
-        return iov_size(iov, iovcnt);
+        return size;
     }
 
     if (nc->receive_disabled) {