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:
committed by
Jason Wang
parent
8faa6cd071
commit
eb3fb50838
@@ -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) {
|
||||
|
||||
@@ -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++) {
|
||||
|
||||
Reference in New Issue
Block a user