From 3cd3f7987d8042b3211b5e503362bee6fd7a2e8f Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Thu, 9 Sep 2021 14:01:48 +0200 Subject: [PATCH] - Cannot reproduce https://github.com/clicon/clixon/issues/245, added sanity chaeck and regression test --- lib/src/clixon_xpath_eval.c | 4 ++++ test/test_netconf.sh | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/lib/src/clixon_xpath_eval.c b/lib/src/clixon_xpath_eval.c index d02c4a01..a5682cda 100644 --- a/lib/src/clixon_xpath_eval.c +++ b/lib/src/clixon_xpath_eval.c @@ -708,6 +708,10 @@ xp_relop(xp_ctx *xc1, int reverse = 0; double n1, n2; + if (xc1 == NULL || xc2 == NULL){ + clicon_err(OE_UNIX, EINVAL, "xc1 or xc2 NULL"); + goto done; + } if ((xr = malloc(sizeof(*xr))) == NULL){ clicon_err(OE_UNIX, errno, "malloc"); goto done; diff --git a/test/test_netconf.sh b/test/test_netconf.sh index 6339b0bc..d05e22c7 100755 --- a/test/test_netconf.sh +++ b/test/test_netconf.sh @@ -295,6 +295,13 @@ expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOe0e1]]>]]>" "^applicationunknown-elementnameerrorFailed to find YANG spec of XML node: name with parent: name in namespace: urn:ietf:params:xml:ns:yang:ietf-interfaces]]>]]>$" +# Negative tests +new "netconf xpath syntax error (api-path not xpath) should fail" +expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationoperation-failederrorxpath parser on line 1: syntax error at or before: ',']]>]]>$" + +new "netconf wrong xpath should fail" +expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + if [ $BE -ne 0 ]; then new "Kill backend" # Check if premature kill