vppapigen: coveriy missing check of return values 02/31302/2
authorOle Troan <ot@cisco.com>
Mon, 15 Feb 2021 23:42:21 +0000 (00:42 +0100)
committerNeale Ranns <neale@graphiant.com>
Tue, 16 Feb 2021 09:15:15 +0000 (09:15 +0000)
Type: fix
Signed-off-by: Ole Troan <ot@cisco.com>
Change-Id: I424c2f283dab99c1856eb8d9a1444486d09e8e29

src/vat2/jsonconvert.c

index 35279ee..fa41e79 100644 (file)
@@ -42,7 +42,8 @@ int vl_api_u8_string_fromjson(cJSON *o, u8 *s, int len)
     unformat_input_t input;
     char *p = cJSON_GetStringValue(o);
     unformat_init_string (&input, p, strlen(p));
-    unformat(&input, "0x%U", unformat_hex_string, s);
+    if (!unformat (&input, "0x%U", unformat_hex_string, s))
+      return -1;
     return 0;
 }
 
@@ -59,7 +60,8 @@ u8string_fromjson(cJSON *o, char *fieldname)
 
     char *p = cJSON_GetStringValue(item);
     unformat_init_string (&input, p, strlen(p));
-    unformat(&input, "0x%U", unformat_hex_string, &s);
+    if (!unformat (&input, "0x%U", unformat_hex_string, &s))
+      return 0;
     return s;
 }