Fixed: [string length validation doesn't work for the entry "" in case it has default value specified](https://github.com/clicon/clixon/issues/563)

This commit is contained in:
Olof hagsand 2024-11-01 09:58:28 +01:00
parent 739d052383
commit 3188e3cc59
3 changed files with 22 additions and 4 deletions

View file

@ -17,6 +17,7 @@ Expected: January 2025
### Corrected Bugs
* Fixed: [string length validation doesn't work for the entry "" in case it has default value specified](https://github.com/clicon/clixon/issues/563)
* Fixed: [SNMP: snmpwalk is slow and can timeout](https://github.com/clicon/clixon/issues/404)
## 7.2.0

View file

@ -1065,6 +1065,13 @@ xml_yang_validate_add(clixon_handle h,
goto done;
goto fail;
}
if (cvtype != CGV_EMPTY && cvtype != CGV_VOID){
if (cv_parse1("", cv, &reason) != 1){
if (xret && netconf_bad_element_xml(xret, "application", yang_argument_get(yt), reason) < 0)
goto done;
goto fail;
}
}
}
else{
if (cv_parse1(body, cv, &reason) != 1){

View file

@ -103,6 +103,7 @@ module example{
}
leaf lstring {
type tstring;
default "somestring";
}
/* here follows unlimited ints */
leaf rint8 {
@ -165,6 +166,7 @@ cat <<EOF > $dclispec/clispec.cli
merge @datamodel, cli_merge();
create @datamodel, cli_create();
show, cli_show_config("candidate", "text");
validate("Validate changes"), cli_validate();
quit("Quit"), cli_quit();
EOF
@ -211,10 +213,11 @@ function testbuiltin(){
}
# Type explicit typed range tests.
# Parameters: 1: type (eg uint8)
# 2: val OK
# 3: eval Invalid value
# 4: post (eg .000 - special for decimal64, others should have "")
# Parameters:
# 1: type (eg uint8)
# 2: val OK
# 3: eval Invalid value
# 4: post (eg .000 - special for decimal64, others should have "")
function testrange(){
t=$1
val=$2
@ -317,6 +320,13 @@ testrange decimal64 1 0 ".000"
# test string with lengthlimit
testrange string "012" "01234567890" ""
# see https://github.com/clicon/clixon/issues/563
new "Netconf set empty string with 1.. range"
expectpart "$($clixon_cli -1f $cfg -l o set lstring \"\")" 0 ""
new "Validate expect fail"
expectpart "$($clixon_cli -1f $cfg -l o validate)" 255 "String length 0 out of range: 1 - 10"
if [ $BE -ne 0 ]; then
new "Kill backend"
# Check if premature kill