mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 19:11:16 +00:00
util: don't validate empty params
If there are no parameters, there is nothing to validate. If params == NULL, memcpy below results in memcpy(sorted, NULL, 0), which is UB. Found by UBSAN. Example of this codepath: virDomainBlockCopy() (where nparams == 0 is valid) -> qemuDomainBlockCopy() Signed-off-by: Oleg Vasilev <oleg.vasilev@virtuozzo.com> Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
This commit is contained in:
parent
b7f7f07542
commit
7b793a00bd
@ -68,6 +68,10 @@ virTypedParamsValidate(virTypedParameterPtr params, int nparams, ...)
|
|||||||
g_autofree virTypedParameterPtr sorted = NULL;
|
g_autofree virTypedParameterPtr sorted = NULL;
|
||||||
g_autofree virTypedParameterPtr keys = NULL;
|
g_autofree virTypedParameterPtr keys = NULL;
|
||||||
|
|
||||||
|
if (!nparams) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
va_start(ap, nparams);
|
va_start(ap, nparams);
|
||||||
|
|
||||||
sorted = g_new0(virTypedParameter, nparams);
|
sorted = g_new0(virTypedParameter, nparams);
|
||||||
|
Loading…
Reference in New Issue
Block a user