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

Peter Krempa posted 103 patches 4 years, 4 months ago
Only 102 patches received!
[PATCH 002/103] virJSONValueObjectAddVArgs: Add check for presence of the ':' separator
Posted by Peter Krempa 4 years, 4 months ago
Enforce that the ':' separator between the key and value is always
present.

Signed-off-by: Peter Krempa <pkrempa@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

Re: [PATCH 002/103] virJSONValueObjectAddVArgs: Add check for presence of the ':' separator
Posted by Ján Tomko 4 years, 4 months ago
On a Thursday in 2021, Peter Krempa wrote:
>Enforce that the ':' separator between the key and value is always
>present.
>
>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> src/util/virjson.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano