Skip to content

Commit

Permalink
Fixed: [Using YANG union with decimal64 and string leads to regexp m…
Browse files Browse the repository at this point in the history
…atch fail #226](#226)
  • Loading branch information
olofhagsand committed May 24, 2021
1 parent d3b614e commit 60c9172
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ Users may have to change how they access the system

### Corrected Bugs

* Fixed: [Using YANG union with decimal64 and string leads to regexp match fail #226](https://github.com/clicon/clixon/issues/226)
* Fixed: [xpath function count did not work properly #224](https://github.com/clicon/clixon/issues/224)
* Fixed: RESTCONF Native: Failed binding of socket in network namespace caused process zombie
* Fixed problems with XPATH composite operations and functions in netconf get/get-config operations.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/clixon_yang.c
Original file line number Diff line number Diff line change
Expand Up @@ -2885,7 +2885,7 @@ yang_abs_schema_nodeid(yang_stmt *yn,
/* If p0 is NULL an entry will be: [i0] which needs to be transformed to [NULL:i0] */
cv = NULL;
while ((cv = cvec_each(nodeid_cvv, cv)) != NULL){
if (cv_type_get(cv) != CGV_STRING)
if (cv_type_get(cv) != CGV_STRING)
cv_type_set(cv, CGV_STRING);
if ((str = cv_string_get(cv)) == NULL || !strlen(str)){
if (cv_string_set(cv, cv_name_get(cv)) < 0){
Expand Down
35 changes: 22 additions & 13 deletions lib/src/clixon_yang_type.c
Original file line number Diff line number Diff line change
Expand Up @@ -743,10 +743,15 @@ static int ys_cv_validate_union(clicon_handle h,yang_stmt *ys, char **reason,
yang_stmt *yrestype, char *type, char *val, yang_stmt **ysubp);

/*!
* @param[out] reason If given and return val is 0, contains a malloced string
* @retval -1 Error (fatal), with errno set to indicate error
* @retval 0 Validation not OK, malloced reason is returned. Free reason with free()
* @retval 1 Validation OK
* @param[in] h Clixon handle
* @param[in] ys Yang statement (union)
* @param[out] reason If given, and return value is 0, contains malloced string
* param[in] yt One of the types in the union
* param[in] type Original type
* @param[in] val Value to match
* @retval -1 Error (fatal), with errno set to indicate error
* @retval 0 Validation not OK, malloced reason is returned. Free reason with free()
* @retval 1 Validation OK
*/
static int
ys_cv_validate_union_one(clicon_handle h,
Expand Down Expand Up @@ -792,6 +797,8 @@ ys_cv_validate_union_one(clicon_handle h,
clicon_err(OE_UNIX, errno, "cv_new");
goto done;
}
if (cvtype == CGV_DEC64)
cv_dec64_n_set(cvt, fraction);
if (val == NULL){ /* Fail validation on NULL */
retval = 0;
goto done;
Expand Down Expand Up @@ -828,21 +835,23 @@ ys_cv_validate_union_one(clicon_handle h,
}

/*! Validate union
* @param[in] h Clixon handle
* @param[in] ys Yang statement (union)
* @param[out] reason If given, and return value is 0, contains malloced string
* @param[in] val Value to match
* @param[out] ysubp Sub-type of ys that matches val
* @retval -1 Error (fatal), with errno set to indicate error
* @retval 0 Validation not OK, malloced reason is returned. Free reason with free()
* @retval 1 Validation OK
* @param[in] h Clixon handle
* @param[in] ys Yang statement (union)
* @param[out] reason If given, and return value is 0, contains malloced string
* param[in] yrestype Resolved Yang type
* param[in] type Original type
* @param[in] val Value to match
* @param[out] ysubp Sub-type of ys that matches val
* @retval -1 Error (fatal), with errno set to indicate error
* @retval 0 Validation not OK, malloced reason is returned. Free reason with free()
* @retval 1 Validation OK
*/
static int
ys_cv_validate_union(clicon_handle h,
yang_stmt *ys,
char **reason,
yang_stmt *yrestype,
char *type, /* orig type */
char *type,
char *val,
yang_stmt **ysubp)
{
Expand Down

0 comments on commit 60c9172

Please sign in to comment.