Recursive (erroneous) Yang specs with recursive grouping/use statement is now fixed: instead of stack overflow, you get an error message and an exit
This commit is contained in:
parent
3855508622
commit
fdfeec96ec
2 changed files with 42 additions and 9 deletions
|
|
@ -85,6 +85,7 @@ Expected: Early March 2020
|
||||||
|
|
||||||
### Corrected Bugs
|
### Corrected Bugs
|
||||||
|
|
||||||
|
* Recursive (erroneous) Yang specs with recursive grouping/use statement is now fixed: instead of stack overflow, you get an error message and an exit
|
||||||
* Fixed: Search function checked only own not for config false statement, should have checked all ancestors. This may affect some state returned in GET calls
|
* Fixed: Search function checked only own not for config false statement, should have checked all ancestors. This may affect some state returned in GET calls
|
||||||
* Fixed: Some restconf errors were wrongly formatted such as: `{"ietf-restconf:errors":{"error":{"rpc-error":` . There should be no `"rpc-error"` level.
|
* Fixed: Some restconf errors were wrongly formatted such as: `{"ietf-restconf:errors":{"error":{"rpc-error":` . There should be no `"rpc-error"` level.
|
||||||
* Fixed: Enabling modstate (CLICON_XMLDB_MODSTATE), changing a revision on a yang, and restarting made the backend daemon exit at start (thanks Matt)
|
* Fixed: Enabling modstate (CLICON_XMLDB_MODSTATE), changing a revision on a yang, and restarting made the backend daemon exit at start (thanks Matt)
|
||||||
|
|
|
||||||
|
|
@ -319,12 +319,13 @@ yang_expand_grouping(yang_stmt *yn)
|
||||||
char *id = NULL;
|
char *id = NULL;
|
||||||
char *prefix = NULL;
|
char *prefix = NULL;
|
||||||
size_t size;
|
size_t size;
|
||||||
|
yang_stmt *yp;
|
||||||
|
|
||||||
/* Cannot use yang_apply here since child-list is modified (is destructive) */
|
/* Cannot use yang_apply here since child-list is modified (is destructive) */
|
||||||
i = 0;
|
i = 0;
|
||||||
while (i < yang_len_get(yn)){
|
while (i < yang_len_get(yn)){
|
||||||
ys = yn->ys_stmt[i];
|
ys = yn->ys_stmt[i];
|
||||||
switch(yang_keyword_get(ys)){
|
switch (yang_keyword_get(ys)){
|
||||||
case Y_USES:
|
case Y_USES:
|
||||||
/* Split argument into prefix and name */
|
/* Split argument into prefix and name */
|
||||||
if (nodeid_split(yang_argument_get(ys), &prefix, &id) < 0)
|
if (nodeid_split(yang_argument_get(ys), &prefix, &id) < 0)
|
||||||
|
|
@ -345,13 +346,28 @@ yang_expand_grouping(yang_stmt *yn)
|
||||||
goto done;
|
goto done;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Check mark flag to see if this grouping (itself) has been expanded
|
/* Check so that this uses statement is not a decendant of the grouping
|
||||||
If not, this needs to be done before we can insert it into
|
* Not that there may be other indirect recursions (I think?)
|
||||||
the 'uses' place */
|
*/
|
||||||
|
yp = yn;
|
||||||
|
do {
|
||||||
|
if (yp == ygrouping){
|
||||||
|
|
||||||
|
clicon_err(OE_YANG, EFAULT, "Yang use of grouping %s in module %s is defined inside the grouping (recursion)",
|
||||||
|
yang_argument_get(ys),
|
||||||
|
yang_argument_get(ys_module(yn))
|
||||||
|
);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
} while((yp = yang_parent_get(yp)) != NULL);
|
||||||
if (yang_flag_get(ygrouping, YANG_FLAG_MARK) == 0){
|
if (yang_flag_get(ygrouping, YANG_FLAG_MARK) == 0){
|
||||||
|
/* Check mark flag to see if this grouping has been expanded before,
|
||||||
|
* here below in the traverse section
|
||||||
|
* A mark could be completely normal (several uses) or it could be a recursion.
|
||||||
|
*/
|
||||||
|
yang_flag_set(ygrouping, YANG_FLAG_MARK); /* Mark as (being) expanded */
|
||||||
if (yang_expand_grouping(ygrouping) < 0)
|
if (yang_expand_grouping(ygrouping) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
yang_flag_set(ygrouping, YANG_FLAG_MARK); /* Mark as expanded */
|
|
||||||
}
|
}
|
||||||
/* Make a copy of the grouping, then make refinements to this copy
|
/* Make a copy of the grouping, then make refinements to this copy
|
||||||
*/
|
*/
|
||||||
|
|
@ -378,7 +394,6 @@ yang_expand_grouping(yang_stmt *yn)
|
||||||
&yn->ys_stmt[i+1],
|
&yn->ys_stmt[i+1],
|
||||||
size);
|
size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Iterate through refinements and modify grouping copy
|
/* Iterate through refinements and modify grouping copy
|
||||||
* See RFC 7950 7.13.2 yrt is the refine target node
|
* See RFC 7950 7.13.2 yrt is the refine target node
|
||||||
*/
|
*/
|
||||||
|
|
@ -423,8 +438,21 @@ yang_expand_grouping(yang_stmt *yn)
|
||||||
/* Second pass since length may have changed */
|
/* Second pass since length may have changed */
|
||||||
for (i=0; i<yang_len_get(yn); i++){
|
for (i=0; i<yang_len_get(yn); i++){
|
||||||
ys = yn->ys_stmt[i];
|
ys = yn->ys_stmt[i];
|
||||||
if (yang_expand_grouping(ys) < 0)
|
if (yang_keyword_get(ys) == Y_GROUPING){
|
||||||
goto done;
|
/* Check mark flag to see if this grouping has been expanded before, here or in the
|
||||||
|
* 'uses' section
|
||||||
|
* A mark could be completely normal (several uses) or it could be a recursion.
|
||||||
|
*/
|
||||||
|
if (yang_flag_get(ys, YANG_FLAG_MARK) == 0){
|
||||||
|
yang_flag_set(ys, YANG_FLAG_MARK); /* Mark as (being) expanded */
|
||||||
|
if (yang_expand_grouping(ys) < 0)
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if (yang_expand_grouping(ys) < 0)
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
|
@ -723,7 +751,11 @@ yang_parse_module(clicon_handle h,
|
||||||
if ((nr = yang_parse_find_match(h, module, revision, &revf, fbuf)) < 0)
|
if ((nr = yang_parse_find_match(h, module, revision, &revf, fbuf)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (nr == 0){
|
if (nr == 0){
|
||||||
clicon_err(OE_YANG, errno, "No yang files found matching \"%s\" in the list of CLICON_YANG_DIRs", module);
|
if (revision)
|
||||||
|
clicon_err(OE_YANG, errno, "No yang files found matching \"%s@%s\" in the list of CLICON_YANG_DIRs",
|
||||||
|
module, revision);
|
||||||
|
else
|
||||||
|
clicon_err(OE_YANG, errno, "No yang files found matching \"%s\" in the list of CLICON_YANG_DIRs", module);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
filename = cbuf_get(fbuf);
|
filename = cbuf_get(fbuf);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue