* Stricter validation detecting duplicate container or leaf in XML.
* Eg `<x><a/><a/></x>` is invalid if `a` is anything else than leaf or leaf-list
This commit is contained in:
parent
861f78f588
commit
12d1b67250
2 changed files with 24 additions and 12 deletions
|
|
@ -31,6 +31,8 @@ Expected: May 2020
|
||||||
|
|
||||||
### API changes on existing protocol/config features (You may have have to change how you use Clixon)
|
### API changes on existing protocol/config features (You may have have to change how you use Clixon)
|
||||||
|
|
||||||
|
* Stricter validation detecting duplicate container or leaf in XML.
|
||||||
|
* Eg `<x><a/><a/></x>` is invalid if `a` is anything else than leaf or leaf-list
|
||||||
* New clixon-lib@2020-04-23.yang revision
|
* New clixon-lib@2020-04-23.yang revision
|
||||||
* Added: stats RPC for clixon XML and memory statistics.
|
* Added: stats RPC for clixon XML and memory statistics.
|
||||||
* Added: restart-plugin RPC for restarting individual plugins without restarting backend.
|
* Added: restart-plugin RPC for restarting individual plugins without restarting backend.
|
||||||
|
|
|
||||||
|
|
@ -785,7 +785,7 @@ check_list_unique_minmax(cxobj *xt,
|
||||||
cxobj *x = NULL;
|
cxobj *x = NULL;
|
||||||
yang_stmt *y;
|
yang_stmt *y;
|
||||||
yang_stmt *yt;
|
yang_stmt *yt;
|
||||||
yang_stmt *yp = NULL; /* previous in list */
|
yang_stmt *yprev = NULL; /* previous in list */
|
||||||
yang_stmt *ye = NULL; /* yang each list to catch emtpy */
|
yang_stmt *ye = NULL; /* yang each list to catch emtpy */
|
||||||
yang_stmt *ych; /* y:s parent node (if choice that ye can compare to) */
|
yang_stmt *ych; /* y:s parent node (if choice that ye can compare to) */
|
||||||
cxobj *xp = NULL; /* previous in list */
|
cxobj *xp = NULL; /* previous in list */
|
||||||
|
|
@ -812,25 +812,35 @@ check_list_unique_minmax(cxobj *xt,
|
||||||
if ((ych = yang_choice(y)) == NULL)
|
if ((ych = yang_choice(y)) == NULL)
|
||||||
ych = y;
|
ych = y;
|
||||||
keyw = yang_keyword_get(y);
|
keyw = yang_keyword_get(y);
|
||||||
if (keyw != Y_LIST && keyw != Y_LEAF_LIST)
|
if (keyw != Y_LIST && keyw != Y_LEAF_LIST){
|
||||||
|
if (yprev != NULL && y == yprev && yang_choice(y)==NULL){
|
||||||
|
/* Only lists and leaf-lists are allowed to be many
|
||||||
|
* This checks duplicate container and leafs
|
||||||
|
*/
|
||||||
|
if (netconf_minmax_elements_xml(xret, x, 1) < 0)
|
||||||
|
goto done;
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
yprev = y; /* Restart min/max count */
|
||||||
continue;
|
continue;
|
||||||
if (yp != NULL){ /* There exists a previous (leaf)list */
|
}
|
||||||
if (y == yp){ /* If same yang as previous x, then skip (eg same list) */
|
if (yprev != NULL){ /* There exists a previous (leaf)list */
|
||||||
|
if (y == yprev){ /* If same yang as previous x, then skip (eg same list) */
|
||||||
nr++;
|
nr++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Check if the list length violates min/max */
|
/* Check if the list length violates min/max */
|
||||||
if ((ret = check_min_max(xp, yp, nr, xret)) < 0)
|
if ((ret = check_min_max(xp, yprev, nr, xret)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
yp = y; /* Restart min/max count */
|
yprev = y; /* Restart min/max count */
|
||||||
xp = x; /* Need a reference to the XML as well */
|
xp = x; /* Need a reference to the XML as well */
|
||||||
nr = 1;
|
nr = 1;
|
||||||
/* Gap analysis: Check if there is any empty list between y and yp
|
/* Gap analysis: Check if there is any empty list between y and yprev
|
||||||
* Note, does not detect empty choice list (too complicated)
|
* Note, does not detect empty choice list (too complicated)
|
||||||
*/
|
*/
|
||||||
if (yt != NULL && ych != ye){
|
if (yt != NULL && ych != ye){
|
||||||
|
|
@ -868,12 +878,12 @@ check_list_unique_minmax(cxobj *xt,
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* yp if set, is a list that has been traversed
|
/* yprev if set, is a list that has been traversed
|
||||||
* This check is made in the loop as well - this is for the last list
|
* This check is made in the loop as well - this is for the last list
|
||||||
*/
|
*/
|
||||||
if (yp){
|
if (yprev){
|
||||||
/* Check if the list length violates min/max */
|
/* Check if the list length violates min/max */
|
||||||
if ((ret = check_min_max(xp, yp, nr, xret)) < 0)
|
if ((ret = check_min_max(xp, yprev, nr, xret)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue