net/tap: check that user tries to define zero queues

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>
This commit is contained in:
Vladimir Sementsov-Ogievskiy
2026-03-18 14:31:43 +03:00
committed by Jason Wang
parent 8faa6cd071
commit eb3fb50838
2 changed files with 9 additions and 0 deletions

View File

@@ -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) {

View 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++) {