virJSONValueObjectAddVArgs: Add check for presence of the ':' separator

Enforce that the ':' separator between the key and value is always
present.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2021-10-06 13:11:10 +02:00
parent eb5b7722ea
commit acf4159556

View File

@ -161,9 +161,9 @@ virJSONValueObjectAddVArgs(virJSONValue *obj,
while ((key = va_arg(args, char *)) != NULL) {
if (strlen(key) < 3) {
if (strlen(key) < 3 || key[1] != ':') {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("argument key '%s' is too short, missing type prefix"),
_("argument key '%s' is too short or malformed"),
key);
return -1;
}