* Fixed: mandatory leaf in a uses statement caused abort
* Occurence was in ietf-yang-patch.yang
This commit is contained in:
parent
270c47b396
commit
6bb6faadc9
4 changed files with 64 additions and 31 deletions
|
|
@ -256,6 +256,18 @@ yang_cv_get(yang_stmt *ys)
|
|||
return ys->ys_cv;
|
||||
}
|
||||
|
||||
/*! Set yang statement CLIgen variable
|
||||
* @param[in] ys Yang statement node
|
||||
* @param[in] cv cligen variable
|
||||
*/
|
||||
int
|
||||
yang_cv_set(yang_stmt *ys,
|
||||
cg_var *cv)
|
||||
{
|
||||
ys->ys_cv = cv;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*! Get yang statement CLIgen variable vector
|
||||
* @param[in] ys Yang statement node
|
||||
*/
|
||||
|
|
@ -456,13 +468,14 @@ int
|
|||
ys_free1(yang_stmt *ys,
|
||||
int self)
|
||||
{
|
||||
cg_var *cv;
|
||||
if (ys->ys_argument){
|
||||
free(ys->ys_argument);
|
||||
ys->ys_argument = NULL;
|
||||
}
|
||||
if (ys->ys_cv){
|
||||
cv_free(ys->ys_cv);
|
||||
ys->ys_cv = NULL;
|
||||
if ((cv = yang_cv_get(ys)) != NULL){
|
||||
cv_free(cv);
|
||||
yang_cv_set(ys, NULL);
|
||||
}
|
||||
if (ys->ys_cvec){
|
||||
cvec_free(ys->ys_cvec);
|
||||
|
|
@ -601,6 +614,8 @@ ys_cp(yang_stmt *ynew,
|
|||
int i;
|
||||
yang_stmt *ycn; /* new child */
|
||||
yang_stmt *yco; /* old child */
|
||||
cg_var *cvn;
|
||||
cg_var *cvo;
|
||||
|
||||
memcpy(ynew, yold, sizeof(*yold));
|
||||
ynew->ys_parent = NULL;
|
||||
|
|
@ -614,11 +629,13 @@ ys_cp(yang_stmt *ynew,
|
|||
clicon_err(OE_YANG, errno, "strdup");
|
||||
goto done;
|
||||
}
|
||||
if (yold->ys_cv)
|
||||
if ((ynew->ys_cv = cv_dup(yold->ys_cv)) == NULL){
|
||||
if ((cvo = yang_cv_get(yold)) != NULL){
|
||||
if ((cvn = cv_dup(cvo)) == NULL){
|
||||
clicon_err(OE_YANG, errno, "cv_dup");
|
||||
goto done;
|
||||
}
|
||||
yang_cv_set(ynew, cvn);
|
||||
}
|
||||
if (yold->ys_cvec)
|
||||
if ((ynew->ys_cvec = cvec_dup(yold->ys_cvec)) == NULL){
|
||||
clicon_err(OE_YANG, errno, "cvec_dup");
|
||||
|
|
@ -1770,8 +1787,7 @@ ys_populate_leaf(clicon_handle h,
|
|||
|
||||
yparent = ys->ys_parent; /* Find parent: list/container */
|
||||
/* 1. Find type specification and set cv type accordingly */
|
||||
if (yang_type_get(ys, &origtype, &yrestype, &options, NULL, NULL, NULL, &fraction_digits)
|
||||
< 0)
|
||||
if (yang_type_get(ys, &origtype, &yrestype, &options, NULL, NULL, NULL, &fraction_digits) < 0)
|
||||
goto done;
|
||||
restype = yrestype?yrestype->ys_argument:NULL;
|
||||
if (clicon_type2cv(origtype, restype, ys, &cvtype) < 0) /* This handles non-resolved also */
|
||||
|
|
@ -1828,7 +1844,7 @@ ys_populate_leaf(clicon_handle h,
|
|||
if ((ret = yang_key_match(yparent, ys->ys_argument)) < 0)
|
||||
goto done;
|
||||
}
|
||||
ys->ys_cv = cv;
|
||||
yang_cv_set(ys, cv);
|
||||
retval = 0;
|
||||
done:
|
||||
if (origtype)
|
||||
|
|
@ -2241,7 +2257,7 @@ ys_populate_feature(clicon_handle h,
|
|||
cv_bool_set(cv, found);
|
||||
if (found)
|
||||
clicon_debug(1, "%s %s:%s", __FUNCTION__, module, feature);
|
||||
ys->ys_cv = cv;
|
||||
yang_cv_set(ys, cv);
|
||||
ok:
|
||||
retval = 0;
|
||||
done:
|
||||
|
|
@ -2495,7 +2511,7 @@ yang_if_feature(clicon_handle h,
|
|||
yang_stmt *yfeat; /* feature yang node */
|
||||
int opand = -1; /* -1:not set, 0:or, 1:and */
|
||||
int enabled = 0;
|
||||
|
||||
cg_var *cv;
|
||||
if ((vec = clicon_strsep(ys->ys_argument, " \t\r\n", &nvec)) == NULL)
|
||||
goto done;
|
||||
/* Two steps: first detect operators
|
||||
|
|
@ -2584,7 +2600,8 @@ yang_if_feature(clicon_handle h,
|
|||
/* Check if this feature is enabled or not
|
||||
* Continue loop to catch unbound features and make verdict at end
|
||||
*/
|
||||
if (yfeat->ys_cv == NULL || !cv_bool_get(yfeat->ys_cv)){ /* disabled */
|
||||
cv = yang_cv_get(yfeat);
|
||||
if (cv == NULL || !cv_bool_get(cv)){ /* disabled */
|
||||
/* if AND then this is permanently disabled */
|
||||
if (opand && enabled)
|
||||
enabled = 0;
|
||||
|
|
@ -3024,14 +3041,15 @@ int
|
|||
yang_mandatory(yang_stmt *ys)
|
||||
{
|
||||
yang_stmt *ym;
|
||||
cg_var *cv;
|
||||
|
||||
/* 1) A leaf, choice, anydata, or anyxml node with a "mandatory"
|
||||
* statement with the value "true". */
|
||||
if (ys->ys_keyword == Y_LEAF || ys->ys_keyword == Y_CHOICE ||
|
||||
ys->ys_keyword == Y_ANYDATA || ys->ys_keyword == Y_ANYXML){
|
||||
if ((ym = yang_find(ys, Y_MANDATORY, NULL)) != NULL){
|
||||
if (ym->ys_cv != NULL) /* shouldnt happen */
|
||||
return cv_bool_get(ym->ys_cv);
|
||||
if ((cv = yang_cv_get(ym)) != NULL) /* shouldnt happen */
|
||||
return cv_bool_get(cv);
|
||||
}
|
||||
}
|
||||
#if 0 /* See note above */
|
||||
|
|
@ -3071,9 +3089,9 @@ yang_config(yang_stmt *ys)
|
|||
yang_stmt *ym;
|
||||
|
||||
if ((ym = yang_find(ys, Y_CONFIG, NULL)) != NULL){
|
||||
if (ym->ys_cv == NULL) /* shouldnt happen */
|
||||
if (yang_cv_get(ym) == NULL) /* shouldnt happen */
|
||||
return 1;
|
||||
return cv_bool_get(ym->ys_cv);
|
||||
return cv_bool_get(yang_cv_get(ym));
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue