From 89f751357d2073f087e9636bb7c6899b6865db4e Mon Sep 17 00:00:00 2001 From: Olof Hagsand Date: Mon, 8 Jul 2019 16:21:27 +0000 Subject: [PATCH] Memory error [Netconf get/get-config :xpath capability does not support namespaces](https://github.com/clicon/clixon/issues/75) --- CHANGELOG.md | 2 +- apps/restconf/restconf_methods.c | 6 +++--- lib/src/clixon_netconf_lib.c | 30 +----------------------------- 3 files changed, 5 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fb75b97..ed1515c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -69,7 +69,7 @@ ### API changes on existing features (you may need to change your code) -* The Clixon API has been extended with namespaces, or namespace contexts in the following cases: +* The Clixon API has been extended with namespaces, or namespace contexts in the following cases [Netconf get/get-config :xpath capability does not support namespaces](https://github.com/clicon/clixon/issues/75) * CLIspec functions have added namespace parameter: * `cli_show_config ` --> `cli_show_config ` * `cli_copy_config ...` --> `cli_copy_config ...` diff --git a/apps/restconf/restconf_methods.c b/apps/restconf/restconf_methods.c index 5c21d3a5..2a6d4059 100644 --- a/apps/restconf/restconf_methods.c +++ b/apps/restconf/restconf_methods.c @@ -191,7 +191,7 @@ api_data_get2(clicon_handle h, yang_stmt *yspec; cxobj *xret = NULL; cxobj *xerr = NULL; /* malloced */ - cxobj *xe = NULL; + cxobj *xe = NULL; /* not malloced */ cxobj **xvec = NULL; size_t xlen; int i; @@ -293,10 +293,10 @@ api_data_get2(clicon_handle h, instance that does not exist, then an error response containing a "404 Not Found" status-line MUST be returned by the server. The error-tag value "invalid-value" is used in this case. */ - if (netconf_invalid_value_xml(&xe, "application", "Instance does not exist") < 0) + if (netconf_invalid_value_xml(&xerr, "application", "Instance does not exist") < 0) goto done; /* override invalid-value default 400 with 404 */ - if (api_return_err(h, r, xe, pretty, use_xml, 404) < 0) + if (api_return_err(h, r, xerr, pretty, use_xml, 404) < 0) goto done; goto ok; } diff --git a/lib/src/clixon_netconf_lib.c b/lib/src/clixon_netconf_lib.c index 2db4e3ea..97e44fbe 100644 --- a/lib/src/clixon_netconf_lib.c +++ b/lib/src/clixon_netconf_lib.c @@ -121,7 +121,7 @@ netconf_invalid_value_xml(cxobj **xret, char *message) { int retval =-1; - cxobj *xerr; + cxobj *xerr = NULL; char *encstr = NULL; if (*xret == NULL){ @@ -162,7 +162,6 @@ netconf_invalid_value(cbuf *cb, char *type, char *message) { -#if 1 int retval = -1; cxobj *xret = NULL; @@ -175,33 +174,6 @@ netconf_invalid_value(cbuf *cb, if (xret) xml_free(xret); return retval; -#else - int retval = -1; - char *encstr = NULL; - - if (cprintf(cb, "" - "%s" - "invalid-value" - "error", - type) <0) - goto err; - if (message){ - if (xml_chardata_encode(&encstr, "%s", message) < 0) - goto done; - if (cprintf(cb, "%s", encstr) < 0) - goto err; - } - if (cprintf(cb, "") <0) - goto err; - retval = 0; - done: - if (encstr) - free(encstr); - return retval; - err: - clicon_err(OE_XML, errno, "cprintf"); - goto done; -#endif } /*! Create Netconf too-big error XML tree according to RFC 6241 Appendix A