diff --git a/net/tap.c b/net/tap.c index e464f62b47..57ffb09885 100644 --- 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) { diff --git a/net/util.c b/net/util.c index 1998a6554e..8265f15548 100644 --- a/net/util.c +++ b/net/util.c @@ -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++) {