Fixed: SEGV when using NETCONF get filter xpath and non-existent key

* eg `select="/ex:table[ex:non-exist='a']`
This commit is contained in:
Olof hagsand 2022-11-01 11:13:40 +01:00
parent 56f4bb45cc
commit e3d621c66d
3 changed files with 18 additions and 4 deletions

View file

@ -83,6 +83,8 @@ Developers may need to change their code
### Corrected Bugs
* Fixed: SEGV when using NETCONF get filter xpath and non-existent key
* eg `select="/ex:table[ex:non-exist='a']`
* Fixed: [CLI Show config JSON with multiple top-level elements is broken](https://github.com/clicon/clixon/issues/381)
* Fixed: [Non-obvious behavior of clixon_snmp after snmpset command when transaction validation returns an error](https://github.com/clicon/clixon/issues/375)
* Fixed by validating writes on ACTION instead of COMMIT since libnetsnmp seems not to accept commit errors

View file

@ -845,10 +845,18 @@ xp_relop(xp_ctx *xc1,
case XO_EQ:
if (s1 == NULL && s2 == NULL)
xr->xc_bool = 1;
else if (s1 == NULL && strlen(s2) == 0)
if (s1 == NULL){
if (strlen(s2) == 0)
xr->xc_bool = 1;
else if (strlen(s1) == 0 && s2 == NULL)
else
xr->xc_bool = 0;
}
else if (s2 == NULL){
if (strlen(s1) == 0)
xr->xc_bool = 1;
else
xr->xc_bool = 0;
}
else
xr->xc_bool = (strcmp(s1, s2)==0);
break;

View file

@ -133,6 +133,10 @@ EOF
new "check datastore using netconf"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-config><source><candidate/></source><filter type=\"xpath\" select=\"/ex:table/ex:parameter[ex:name='x']\" xmlns:ex=\"urn:example:clixon\" /></get-config></rpc>" "" "<rpc-reply $DEFAULTNS><data>$XML</data></rpc-reply>"
# Test not right context but could not find other test where it fits
new "negative test"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-config><source><candidate/></source><filter type=\"xpath\" select=\"/ex:table[ex:parameter='x']\" xmlns:ex=\"urn:example:clixon\" /></get-config></rpc>" "" "<rpc-reply $DEFAULTNS><data/></rpc-reply>"
new "check datastore direct access"
expectpart "$($clixon_util_datastore -d candidate -b $dir -y $fyang -Y ${YANG_INSTALLDIR} -Y $dir get /)" 0 "$XML"