[PATCH 002/103] virJSONValueObjectAddVArgs: Add check for presence of the ':' separator

Peter Krempa pkrempa at redhat.com
Thu Oct 7 15:16:50 UTC 2021


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

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/util/virjson.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/util/virjson.c b/src/util/virjson.c
index 70ea71b505..d7e72af8f9 100644
--- a/src/util/virjson.c
+++ b/src/util/virjson.c
@@ -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;
         }
-- 
2.31.1




More information about the libvir-list mailing list