network: ensure nparams is non-NULL and non-negative

The typed parameter array length must be non-NULL and either 0, or a
positive number.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2024-03-15 10:47:07 +00:00
parent ded74b3369
commit e5b7f1e266

View File

@ -1577,6 +1577,9 @@ virNetworkPortGetParameters(virNetworkPortPtr port,
virCheckNetworkPortReturn(port, -1);
conn = port->net->conn;
virCheckNonNullArgGoto(nparams, error);
virCheckNonNegativeArgGoto(*nparams, error);
if (conn->networkDriver && conn->networkDriver->networkPortGetParameters) {
int ret;
ret = conn->networkDriver->networkPortGetParameters(port, params, nparams, flags);