Permalink
Browse files

Validate type of the json root

Prevents another segfault.
  • Loading branch information...
ydahhrk committed Dec 20, 2018
1 parent 4e8b1de commit 061231b5d8624e204c08965ba503a017cd911c1c
Showing with 5 additions and 0 deletions.
  1. +5 −0 src/usr/common/nl/json.c
@@ -21,6 +21,8 @@ static char *iname;
static jframework fw;
static bool force;

static int print_type_error(char const *field, cJSON *json,
char const *expected);
static int do_parsing(char *buffer);
static int parse_siit_json(cJSON *json);
static int parse_nat64_json(cJSON *json);
@@ -56,6 +58,9 @@ static int prepare_instance(cJSON *json)
iname = NULL;
fw = 0;

if (json->type != cJSON_Object)
return print_type_error("root", json, "Object");

for (json = json->child; json; json = json->next) {
if (strcasecmp(OPTNAME_INAME, json->string) == 0) {
if (iname)

0 comments on commit 061231b

Please sign in to comment.