]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
net/tap: check that user tries to define zero queues
authorVladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Wed, 18 Mar 2026 11:31:43 +0000 (14:31 +0300)
committerJason Wang <jasowang@redhat.com>
Tue, 26 May 2026 06:09:31 +0000 (14:09 +0800)
Add check for queues parameter to be non-zero, and for fd/fds
parameters to be non-empty.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Signed-off-by: Jason Wang <jasowang@redhat.com>
net/tap.c
net/util.c

index e464f62b473f452c100d75b59f8c4d16a15bea72..57ffb09885c0fda5321cf1b7e164ee3643ddc596 100644 (file)
--- a/net/tap.c
+++ b/net/tap.c
@@ -807,6 +807,10 @@ static int tap_parse_fds_and_queues(const NetdevTapOptions *tap, int **fds,
             error_setg(errp, "queues exceeds maximum %d", INT_MAX);
             return -1;
         }
+        if (tap->queues == 0) {
+            error_setg(errp, "queues must be greater than zero");
+            return -1;
+        }
         queues = tap->queues;
         *fds = NULL;
     } else if (tap->fd || tap->fds) {
index 1998a6554e0993ca1adc719333015568f85d49d1..8265f1554847b59ffa758cb78d3cbb8d2b097da2 100644 (file)
@@ -94,6 +94,11 @@ int net_parse_fds(const char *fds_param, int **fds, int expected_nfds,
         return -1;
     }
 
+    if (nfds == 0) {
+        error_setg(errp, "no fds passed");
+        return -1;
+    }
+
     *fds = g_new(int, nfds);
 
     for (i = 0; i < nfds; i++) {