]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virJSONValueObjectAddVArgs: Add check for presence of the ':' separator
authorPeter Krempa <pkrempa@redhat.com>
Wed, 6 Oct 2021 11:11:10 +0000 (13:11 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 12 Oct 2021 08:25:59 +0000 (10:25 +0200)
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>
src/util/virjson.c

index 26491bd6c73801a1fa3a32dbd99408b2820df67b..4aabad15ef26e59862eb33c85920b0255fcf89e6 100644 (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;
         }