diff --git a/apps/restconf/restconf_methods.c b/apps/restconf/restconf_methods.c index 8c1a9073..4fd549dc 100644 --- a/apps/restconf/restconf_methods.c +++ b/apps/restconf/restconf_methods.c @@ -408,7 +408,7 @@ api_data_put(clicon_handle h, cbuf *cbx = NULL; cxobj *x; cxobj *xbot = NULL; - cxobj *xtop; + cxobj *xtop = NULL; cxobj *xp; yang_node *y = NULL; yang_spec *yspec; diff --git a/datastore/text/clixon_xmldb_text.c b/datastore/text/clixon_xmldb_text.c index e96d7067..0013948f 100644 --- a/datastore/text/clixon_xmldb_text.c +++ b/datastore/text/clixon_xmldb_text.c @@ -773,6 +773,11 @@ text_put(xmldb_handle xh, clicon_err(OE_XML, 0, "dbfile NULL"); goto done; } + if (x1 && strcmp(xml_name(x1),"config")!=0){ + clicon_err(OE_XML, 0, "Top-level symbol of modification tree is %s, expected \"config\"", + xml_name(x1)); + goto done; + } if ((yspec = th->th_yangspec) == NULL){ clicon_err(OE_YANG, ENOENT, "No yang spec"); goto done; @@ -797,8 +802,13 @@ text_put(xmldb_handle xh, if (singleconfigroot(x0, &x0) < 0) goto done; } - assert(strcmp(xml_name(x0),"config")==0); /* Here x0 looks like: ... */ + if (strcmp(xml_name(x0),"config")!=0){ + clicon_err(OE_XML, 0, "Top-level symbol is %s, expected \"config\"", + xml_name(x0)); + goto done; + } + /* Validate existing config tree */ if (xml_apply(x0, CX_ELMNT, xml_spec_populate, yspec) < 0) goto done; diff --git a/lib/src/clixon_xml_map.c b/lib/src/clixon_xml_map.c index 1bd2409d..a8394fd6 100644 --- a/lib/src/clixon_xml_map.c +++ b/lib/src/clixon_xml_map.c @@ -1473,8 +1473,10 @@ api_path2xml_vec(char **vec, yang_stmt *y = NULL; if ((name = vec[0]) == NULL){ - *xpathp = x0; - *ypathp = y0; + if (xpathp) + *xpathp = x0; + if (ypathp) + *ypathp = y0; return 0; } /* E.g "x=1,2" -> name:x restval=1,2 */ /* restval is RFC 3896 encoded */ diff --git a/lib/src/clixon_xml_parse.y b/lib/src/clixon_xml_parse.y index 1ba389a1..a1051e8d 100644 --- a/lib/src/clixon_xml_parse.y +++ b/lib/src/clixon_xml_parse.y @@ -168,12 +168,12 @@ xml_parse_bslash1(struct xml_parse_yacc_arg *ya, cxobj *xc; if (strcmp(xml_name(x), name)){ - clicon_err(OE_XML, 0, "Sanity check failed: %s vs %s", + clicon_err(OE_XML, 0, "XML parse sanity check failed: %s vs %s", xml_name(x), name); goto done; } if (xml_namespace(x)!=NULL){ - clicon_err(OE_XML, 0, "Sanity check failed: %s:%s vs %s\n", + clicon_err(OE_XML, 0, "XML parse sanity check failed: %s:%s vs %s\n", xml_namespace(x), xml_name(x), name); goto done; }