diff --git a/CHANGELOG.md b/CHANGELOG.md index 9da45a11..7073e5a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,8 +45,18 @@ Users may have to change how they access the system * If backend is started with `-s startup` or `-s running` then `_db` is read if `.d/0.xml` is not found * Openssl mandatory for all configs, not only restconf +### C/CLI-API changes on existing features + +Developers may need to change their code + +* XML encoding added a `quotes` parameter for attribute encoding, update as follows: + * `xml_chardata_encode(e, fmt,...)` --> `xml_chardata_encode(e, 0, fmt,...)` + * `xml_chardata_cbuf_append(cb, str)` --> `xml_chardata_cbuf_append(cb, 0, str)` + ### Corrected Bugs +* Fixed: backend exit when receiving invalid NETCONF get select XPath + * Added XML encoding to XPaths in `select` attribute * Fixed: Fail on return errors when reading from datastore * Can happen if running is not upgraded for example * Fixed: [Duplicate config files in configdir causes merge problems -> set ? = NULL](https://github.com/clicon/clixon/issues/510) diff --git a/apps/backend/backend_client.c b/apps/backend/backend_client.c index 6fc07428..01cfb6b4 100644 --- a/apps/backend/backend_client.c +++ b/apps/backend/backend_client.c @@ -1326,7 +1326,7 @@ from_client_get_schema(clixon_handle h, if (clicon_file_cbuf(filename, cbyang) < 0) goto done; } - xml_chardata_cbuf_append(cbret, cbuf_get(cbyang)); + xml_chardata_cbuf_append(cbret, 0, cbuf_get(cbyang)); cprintf(cbret, ""); ok: retval = 0; @@ -1677,7 +1677,7 @@ from_client_msg(clixon_handle h, if ((ret = clixon_xml_parse_string(msg, YB_RPC, yspec, &xt, &xret)) < 0){ if (netconf_malformed_message(cbret, "XML parse error") < 0) goto done; - goto done; + goto reply; } if (ret == 0){ if (clixon_xml2cbuf(cbret, xret, 0, 0, NULL, -1, 0) < 0) diff --git a/apps/backend/backend_get.c b/apps/backend/backend_get.c index 36a0b65e..77f4cf03 100644 --- a/apps/backend/backend_get.c +++ b/apps/backend/backend_get.c @@ -808,6 +808,7 @@ get_common(clixon_handle h, char *reason = NULL; cbuf *cbmsg = NULL; /* For error msg */ char *xpath0; + char *xpath01 = NULL; cbuf *cbreason = NULL; int list_pagination = 0; cxobj **xvec = NULL; @@ -828,6 +829,8 @@ get_common(clixon_handle h, if ((xfilter = xml_find(xe, "filter")) != NULL){ if ((xpath0 = xml_find_value(xfilter, "select"))==NULL) xpath0 = "/"; + if (xml_chardata_decode(&xpath01, "%s", xpath0) < 0) + goto done; /* Create namespace context for xpath from * The set of namespace declarations are those in scope on the * element. @@ -835,7 +838,7 @@ get_common(clixon_handle h, else if (xml_nsctx_node(xfilter, &nsc0) < 0) goto done; - if ((ret = xpath2canonical(xpath0, nsc0, yspec, &xpath, &nsc, &cbreason)) < 0) + if ((ret = xpath2canonical(xpath01, nsc0, yspec, &xpath, &nsc, &cbreason)) < 0) goto done; if (ret == 0){ if (netconf_bad_attribute(cbret, "application", @@ -1037,6 +1040,8 @@ get_common(clixon_handle h, xml_free(xerr); if (xpath) free(xpath); + if (xpath01) + free(xpath01); return retval; } diff --git a/lib/clixon/clixon_string.h b/lib/clixon/clixon_string.h index f5a6c815..5e04d013 100644 --- a/lib/clixon/clixon_string.h +++ b/lib/clixon/clixon_string.h @@ -95,8 +95,8 @@ char *clixon_string_del_join(char *str1, char *del, char *str2); int clixon_strsplit(char *nodeid, const int delim, char **prefix, char **id); int uri_str2cvec(char *string, char delim1, char delim2, int decode, cvec **cvp); int uri_percent_encode(char **encp, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); -int xml_chardata_encode(char **escp, const char *fmt, ... ) __attribute__ ((format (printf, 2, 3))); -int xml_chardata_cbuf_append(cbuf *cb, char *str); +int xml_chardata_encode(char **escp, int quote, const char *fmt, ... ) __attribute__ ((format (printf, 3, 4))); +int xml_chardata_cbuf_append(cbuf *cb, int quote, char *str); int xml_chardata_decode(char **escp, const char *fmt,...); int uri_percent_decode(char *enc, char **str); diff --git a/lib/src/clixon_netconf_lib.c b/lib/src/clixon_netconf_lib.c index 0ad5d8af..c2d91922 100644 --- a/lib/src/clixon_netconf_lib.c +++ b/lib/src/clixon_netconf_lib.c @@ -134,7 +134,7 @@ netconf_in_use(cbuf *cb, type) <0) goto err; if (message){ - if (xml_chardata_encode(&encstr, "%s", message) < 0) + if (xml_chardata_encode(&encstr, 0, "%s", message) < 0) goto done; if (cprintf(cb, "%s", encstr) < 0) goto err; @@ -189,7 +189,7 @@ netconf_invalid_value_xml(cxobj **xret, "error", type) < 0) goto done; if (message){ - if (xml_chardata_encode(&encstr, "%s", message) < 0) + if (xml_chardata_encode(&encstr, 0, "%s", message) < 0) goto done; if (clixon_xml_parse_va(YB_NONE, NULL, &xerr, NULL, "%s", encstr) < 0) @@ -256,7 +256,7 @@ netconf_too_big(cbuf *cb, type) <0) goto err; if (message){ - if (xml_chardata_encode(&encstr, "%s", message) < 0) + if (xml_chardata_encode(&encstr, 0, "%s", message) < 0) goto done; if (cprintf(cb, "%s", encstr) < 0) goto err; @@ -313,7 +313,7 @@ netconf_missing_attribute_xml(cxobj **xret, "error", type, attr) < 0) goto done; if (message){ - if (xml_chardata_encode(&encstr, "%s", message) < 0) + if (xml_chardata_encode(&encstr, 0, "%s", message) < 0) goto done; if (clixon_xml_parse_va(YB_NONE, NULL, &xerr, NULL, "%s", encstr) < 0) @@ -429,7 +429,7 @@ netconf_bad_attribute_xml(cxobj **xret, "error", type, info) < 0) goto done; if (message){ - if (xml_chardata_encode(&encstr, "%s", message) < 0) + if (xml_chardata_encode(&encstr, 0, "%s", message) < 0) goto done; if (clixon_xml_parse_va(YB_NONE, NULL, &xerr, NULL, "%s", encstr) < 0) @@ -469,7 +469,7 @@ netconf_unknown_attribute(cbuf *cb, NETCONF_BASE_NAMESPACE, type, info) <0) goto err; if (message){ - if (xml_chardata_encode(&encstr, "%s", message) < 0) + if (xml_chardata_encode(&encstr, 0, "%s", message) < 0) goto done; if (cprintf(cb, "%s", encstr) < 0) goto err; @@ -529,7 +529,7 @@ netconf_common_xml(cxobj **xret, type, tag, infotag, element, infotag) < 0) goto done; if (message){ - if (xml_chardata_encode(&encstr, "%s", message) < 0) + if (xml_chardata_encode(&encstr, 0, "%s", message) < 0) goto done; if (clixon_xml_parse_va(YB_NONE, NULL, &xerr, NULL, "%s", encstr) < 0) @@ -799,7 +799,7 @@ netconf_access_denied_xml(cxobj **xret, "error", type) < 0) goto done; if (message){ - if (xml_chardata_encode(&encstr, "%s", message) < 0) + if (xml_chardata_encode(&encstr, 0, "%s", message) < 0) goto done; if (clixon_xml_parse_va(YB_NONE, NULL, &xerr, NULL, "%s", encstr) < 0) @@ -838,7 +838,7 @@ netconf_lock_denied(cbuf *cb, NETCONF_BASE_NAMESPACE, info) <0) goto err; if (message){ - if (xml_chardata_encode(&encstr, "%s", message) < 0) + if (xml_chardata_encode(&encstr, 0, "%s", message) < 0) goto done; if (cprintf(cb, "%s", encstr) < 0) goto err; @@ -879,7 +879,7 @@ netconf_resource_denied(cbuf *cb, NETCONF_BASE_NAMESPACE, type) <0) goto err; if (message){ - if (xml_chardata_encode(&encstr, "%s", message) < 0) + if (xml_chardata_encode(&encstr, 0, "%s", message) < 0) goto done; if (cprintf(cb, "%s", encstr) < 0) goto err; @@ -921,7 +921,7 @@ netconf_rollback_failed(cbuf *cb, NETCONF_BASE_NAMESPACE, type) <0) goto err; if (message){ - if (xml_chardata_encode(&encstr, "%s", message) < 0) + if (xml_chardata_encode(&encstr, 0, "%s", message) < 0) goto done; if (cprintf(cb, "%s", encstr) < 0) goto err; @@ -962,7 +962,7 @@ netconf_data_exists(cbuf *cb, NETCONF_BASE_NAMESPACE) <0) goto err; if (message){ - if (xml_chardata_encode(&encstr, "%s", message) < 0) + if (xml_chardata_encode(&encstr, 0, "%s", message) < 0) goto done; if (cprintf(cb, "%s", encstr) < 0) goto err; @@ -1047,7 +1047,7 @@ netconf_data_missing_xml(cxobj **xret, "error") < 0) goto done; if (message){ - if (xml_chardata_encode(&encstr, "%s", message) < 0) + if (xml_chardata_encode(&encstr, 0, "%s", message) < 0) goto done; if (clixon_xml_parse_va(YB_NONE, NULL, &xerr, NULL, "%s", encstr) < 0) @@ -1101,7 +1101,7 @@ netconf_missing_choice_xml(cxobj **xret, /* error-path: Path to the element with the missing choice. */ if (xml2xpath(x, NULL, 0, 0, &path) < 0) goto done; - if (xml_chardata_encode(&encpath, "%s", path) < 0) + if (xml_chardata_encode(&encpath, 0, "%s", path) < 0) goto done; if (clixon_xml_parse_va(YB_NONE, NULL, &xerr, NULL, "application" @@ -1115,7 +1115,7 @@ netconf_missing_choice_xml(cxobj **xret, name) < 0) goto done; if (message){ - if (xml_chardata_encode(&encstr, "%s", message) < 0) + if (xml_chardata_encode(&encstr, 0, "%s", message) < 0) goto done; if (clixon_xml_parse_va(YB_NONE, NULL, &xerr, NULL, "%s", encstr) < 0) @@ -1178,7 +1178,7 @@ netconf_operation_not_supported_xml(cxobj **xret, type) < 0) goto done; if (message){ - if (xml_chardata_encode(&encstr, "%s", message) < 0) + if (xml_chardata_encode(&encstr, 0, "%s", message) < 0) goto done; if (clixon_xml_parse_va(YB_NONE, NULL, &xerr, NULL, "%s", encstr) < 0) @@ -1296,7 +1296,7 @@ netconf_operation_failed_xml(cxobj **xret, type) < 0) goto done; if (message){ - if (xml_chardata_encode(&encstr, "%s", message) < 0) + if (xml_chardata_encode(&encstr, 0, "%s", message) < 0) goto done; if (clixon_xml_parse_va(YB_NONE, NULL, &xerr, NULL, "%s", encstr) < 0) @@ -1384,7 +1384,7 @@ netconf_malformed_message_xml(cxobj **xret, "error") < 0) goto done; if (message){ - if (xml_chardata_encode(&encstr, "%s", message) < 0) + if (xml_chardata_encode(&encstr, 0, "%s", message) < 0) goto done; if (clixon_xml_parse_va(YB_NONE, NULL, &xerr, NULL, "%s", encstr) < 0) @@ -1479,7 +1479,7 @@ netconf_data_not_unique_xml(cxobj **xret, goto done; if (xml2xpath(x, NULL, 0, 0, &path) < 0) goto done; - if (xml_chardata_encode(&encpath, "%s", path) < 0) + if (xml_chardata_encode(&encpath, 0, "%s", path) < 0) goto done; while ((cvi = cvec_each(cvk, cvi)) != NULL){ if (clixon_xml_parse_va(YB_NONE, NULL, &xinfo, NULL, @@ -1539,7 +1539,7 @@ netconf_minmax_elements_xml(cxobj **xret, if (xml_parent(xp)){ /* Dont include root, eg */ if (xml2xpath(xp, NULL, 0, 0, &path) < 0) goto done; - if (xml_chardata_encode(&encpath, "%s", path) < 0) + if (xml_chardata_encode(&encpath, 0, "%s", path) < 0) goto done; } if (clixon_xml_parse_va(YB_NONE, NULL, &xerr, NULL, "protocol" @@ -1817,7 +1817,7 @@ netconf_capabilites(clixon_handle h, /* Check if RFC7895 loaded and revision found */ if ((ietf_yang_library_revision = yang_modules_revision(h)) != NULL){ - if (xml_chardata_encode(&encstr, "urn:ietf:params:netconf:capability:yang-library:1.0?revision=%s&module-set-id=%s", + if (xml_chardata_encode(&encstr, 0, "urn:ietf:params:netconf:capability:yang-library:1.0?revision=%s&module-set-id=%s", ietf_yang_library_revision, module_set_id) < 0) goto done; @@ -1838,7 +1838,7 @@ netconf_capabilites(clixon_handle h, cprintf(cb, "urn:ietf:params:netconf:capability:xpath:1.0"); /* rfc6243 with-defaults capability modes */ cprintf(cb, ""); - xml_chardata_cbuf_append(cb, "urn:ietf:params:netconf:capability:with-defaults:1.0?basic-mode=explicit&also-supported=report-all,trim,report-all-tagged"); + xml_chardata_cbuf_append(cb, 0, "urn:ietf:params:netconf:capability:with-defaults:1.0?basic-mode=explicit&also-supported=report-all,trim,report-all-tagged"); cprintf(cb, ""); /* RFC5277 Notification Capability */ cprintf(cb, "%s", NETCONF_NOTIFICATION_CAPABILITY); diff --git a/lib/src/clixon_proc.c b/lib/src/clixon_proc.c index 65362a0f..c6b59212 100644 --- a/lib/src/clixon_proc.c +++ b/lib/src/clixon_proc.c @@ -826,9 +826,9 @@ clixon_process_status(clixon_handle h, * command) and therefore needs explicit encoding */ for (i=0; ipe_argc-1; i++){ if (i) - if (xml_chardata_cbuf_append(cbret, " ") < 0) + if (xml_chardata_cbuf_append(cbret, 0, " ") < 0) goto done; - if (xml_chardata_cbuf_append(cbret, pe->pe_argv[i]) < 0) + if (xml_chardata_cbuf_append(cbret, 0, pe->pe_argv[i]) < 0) goto done; } cprintf(cbret, ""); diff --git a/lib/src/clixon_proto_client.c b/lib/src/clixon_proto_client.c index 8ac29d5e..b5d69edd 100644 --- a/lib/src/clixon_proto_client.c +++ b/lib/src/clixon_proto_client.c @@ -549,9 +549,11 @@ clicon_rpc_get_config(clixon_handle h, cprintf(cb, " %s", NETCONF_MESSAGE_ID_ATTR); /* XXX: use incrementing sequence */ cprintf(cb, "><%s/>", db); if (xpath && strlen(xpath)){ - cprintf(cb, "<%s:filter %s:type=\"xpath\" %s:select=\"%s\"", - NETCONF_BASE_PREFIX, NETCONF_BASE_PREFIX, NETCONF_BASE_PREFIX, - xpath); + cprintf(cb, "<%s:filter %s:type=\"xpath\" %s:select=\"", + NETCONF_BASE_PREFIX, NETCONF_BASE_PREFIX, NETCONF_BASE_PREFIX); + if (xml_chardata_cbuf_append(cb, 1, xpath) < 0) + goto done; + cprintf(cb, "\""); if (xml_nsctx_cbuf(cb, nsc) < 0) goto done; cprintf(cb, "/>"); @@ -1051,9 +1053,11 @@ clicon_rpc_get2(clixon_handle h, cprintf(cb, ">"); /* get */ /* If xpath, add a filter */ if (xpath && strlen(xpath)) { - cprintf(cb, "<%s:filter %s:type=\"xpath\" %s:select=\"%s\"", - NETCONF_BASE_PREFIX, NETCONF_BASE_PREFIX, NETCONF_BASE_PREFIX, - xpath); + cprintf(cb, "<%s:filter %s:type=\"xpath\" %s:select=\"", + NETCONF_BASE_PREFIX, NETCONF_BASE_PREFIX, NETCONF_BASE_PREFIX); + if (xml_chardata_cbuf_append(cb, 1, xpath) < 0) + goto done; + cprintf(cb, "\""); if (xml_nsctx_cbuf(cb, nsc) < 0) goto done; cprintf(cb, "/>"); @@ -1208,9 +1212,11 @@ clicon_rpc_get_pageable_list(clixon_handle h, cprintf(cb, ">"); /* get */ /* If xpath, add a filter */ if (xpath && strlen(xpath)) { - cprintf(cb, "<%s:filter %s:type=\"xpath\" %s:select=\"%s\"", - NETCONF_BASE_PREFIX, NETCONF_BASE_PREFIX, NETCONF_BASE_PREFIX, - xpath); + cprintf(cb, "<%s:filter %s:type=\"xpath\" %s:select=\"", + NETCONF_BASE_PREFIX, NETCONF_BASE_PREFIX, NETCONF_BASE_PREFIX); + if (xml_chardata_cbuf_append(cb, 1, xpath) < 0) + goto done; + cprintf(cb, "\""); if (xml_nsctx_cbuf(cb, nsc) < 0) goto done; cprintf(cb, "/>"); @@ -1668,11 +1674,14 @@ clicon_rpc_create_subscription(clixon_handle h, cprintf(cb, ">"); cprintf(cb, "" "%s" - "" - "", + "" ""); cprintf(cb, ""); if ((msg = clicon_msg_encode(session_id, "%s", cbuf_get(cb))) == NULL) goto done; diff --git a/lib/src/clixon_string.c b/lib/src/clixon_string.c index 23453526..f7bed5b8 100644 --- a/lib/src/clixon_string.c +++ b/lib/src/clixon_string.c @@ -374,10 +374,9 @@ uri_percent_encode(char **encp, va_start(args, fmt); /* real */ fmtlen = vsnprintf(str, fmtlen, fmt, args) + 1; va_end(args); - /* Now str is the combined fmt + ... */ - - /* Step (2) encode and expand str --> enc */ - /* This is max */ + /* Now str is the combined fmt + ... + * Step (2) encode and expand str --> enc + * This is max */ len = strlen(str)*3+1; if ((enc = malloc(len)) == NULL){ clixon_err(OE_UNIX, errno, "malloc"); @@ -462,13 +461,14 @@ uri_percent_decode(char *enc, /*! Encode escape characters according to XML definition * * @param[out] encp Encoded malloced output string + * @param[in] quote Also encode ' and " (eg for attributes) * @param[in] fmt Not-encoded input string (stdarg format string) * @param[in] ... stdarg variable parameters * @retval 0 OK * @retval -1 Error * @code * char *encstr = NULL; - * if (xml_chardata_encode(&encstr, "fmtstr<>& %s", "substr<>") < 0) + * if (xml_chardata_encode(&encstr, 0, "fmtstr<>& %s", "substr<>") < 0) * err; * if (encstr) * free(encstr); @@ -487,6 +487,7 @@ uri_percent_decode(char *enc, */ int xml_chardata_encode(char **escp, + int quote, const char *fmt,...) { int retval = -1; @@ -512,10 +513,9 @@ xml_chardata_encode(char **escp, va_start(args, fmt); /* real */ fmtlen = vsnprintf(str, fmtlen, fmt, args) + 1; va_end(args); - /* Now str is the combined fmt + ... */ - - /* Step (2) encode and expand str --> enc */ - /* First compute length (do nothing) */ + /* Now str is the combined fmt + ... + * Step (2) encode and expand str --> enc + * First compute length (do nothing) */ len = 0; cdata = 0; slen = strlen(str); for (i=0; i': len += strlen(">"); break; + case '\'': + if (quote) + len += strlen("'"); + else + len++; + break; + case '"': + if (quote) + len += strlen("""); + else + len++; + break; default: len++; } @@ -551,7 +563,6 @@ xml_chardata_encode(char **escp, goto done; } memset(esc, 0, len); - /* Same code again, but now actually encode into output buffer */ j = 0; cdata = 0; slen = strlen(str); @@ -592,6 +603,28 @@ xml_chardata_encode(char **escp, } j += l; break; + case '\'': + if (quote){ + if ((l=snprintf(&esc[j], 7, "'")) < 0){ + clixon_err(OE_UNIX, errno, "snprintf"); + goto done; + } + j += l; + } + else + esc[j++] = str[i]; + break; + case '"': + if (quote){ + if ((l=snprintf(&esc[j], 7, """)) < 0){ + clixon_err(OE_UNIX, errno, "snprintf"); + goto done; + } + j += l; + } + else + esc[j++] = str[i]; + break; default: esc[j++] = str[i]; } @@ -609,24 +642,25 @@ xml_chardata_encode(char **escp, /*! Escape characters according to XML definition and append to cbuf * * @param[in] cb CLIgen buf + * @param[in] quote Also encode ' and " (eg for attributes) * @param[in] str Not-encoded input string * @retdata 0 OK * @see xml_chardata_encode for the generic function */ int xml_chardata_cbuf_append(cbuf *cb, + int quote, char *str) { - int retval = -1; - int i; - int cdata; /* when set, skip encoding */ + int retval = -1; + int i; + int cdata; /* when set, skip encoding */ size_t len; /* The orignal of this code is in xml_chardata_encode */ /* Step: encode and expand str --> enc */ /* Same code again, but now actually encode into output buffer */ cdata = 0; - len = strlen(str); for (i=0; i': + cbuf_append_str(cb, ">"); + break; + case '\'': + if (quote) + cbuf_append_str(cb, "'"); + else + cbuf_append(cb, str[i]); + break; + case '"': + if (quote) + cbuf_append_str(cb, """); + else + cbuf_append(cb, str[i]); + break; + default: + cbuf_append(cb, str[i]); } - cbuf_append_str(cb, "<"); - break; - case '>': - cbuf_append_str(cb, ">"); - break; - default: - cbuf_append(cb, str[i]); - } } retval = 0; - // done: return retval; } diff --git a/lib/src/clixon_xml_io.c b/lib/src/clixon_xml_io.c index 31e022e2..1246aa24 100644 --- a/lib/src/clixon_xml_io.c +++ b/lib/src/clixon_xml_io.c @@ -264,7 +264,7 @@ xml2file_recurse(FILE *f, case CX_BODY: if ((val = xml_value(x)) == NULL) /* incomplete tree */ break; - if (xml_chardata_encode(&encstr, "%s", val) < 0) + if (xml_chardata_encode(&encstr, 0, "%s", val) < 0) goto done; (*fn)(f, "%s", encstr); break; @@ -586,7 +586,7 @@ xml2cbuf_recurse(cbuf *cb, case CX_BODY: if ((val = xml_value(x)) == NULL) /* incomplete tree */ break; - if (xml_chardata_cbuf_append(cb, val) < 0) + if (xml_chardata_cbuf_append(cb, 0, val) < 0) goto done; break; case CX_ATTR: @@ -856,7 +856,7 @@ _xml_parse(const char *str, int failed = 0; /* yang assignment */ int i; - clixon_debug(CLIXON_DBG_XML | CLIXON_DBG_DETAIL, ""); + clixon_debug(CLIXON_DBG_PARSE, "%s", str); if (strlen(str) == 0){ return 1; /* OK */ } @@ -899,7 +899,6 @@ _xml_parse(const char *str, if (ret == 0) failed++; break; - case YB_MODULE_NEXT: if ((ret = xml_bind_yang(NULL, x, YB_MODULE, yspec, xerr)) < 0) goto done; @@ -935,6 +934,7 @@ _xml_parse(const char *str, goto done; retval = 1; done: + clixon_debug(CLIXON_DBG_PARSE, "retval:%d", retval); clixon_xml_parsel_exit(&xy); if (xy.xy_parse_string != NULL) free(xy.xy_parse_string); @@ -1332,13 +1332,13 @@ xml_diff2cbuf_leaf(cbuf *cb, } /* Encode data to XML */ if (b0){ - if (xml_chardata_encode(&e0, "%s", b0) < 0) + if (xml_chardata_encode(&e0, 0, "%s", b0) < 0) goto done; } else e0 = NULL; if (b1){ - if (xml_chardata_encode(&e1, "%s", b1) < 0) + if (xml_chardata_encode(&e1, 0, "%s", b1) < 0) goto done; } else diff --git a/lib/src/clixon_xml_sort.c b/lib/src/clixon_xml_sort.c index bd091095..e1492781 100644 --- a/lib/src/clixon_xml_sort.c +++ b/lib/src/clixon_xml_sort.c @@ -1397,7 +1397,7 @@ xml_find_index_yang(cxobj *xp, revert++; break; } - if (xml_chardata_encode(&encstr, "%s", cv_string_get(cvi)) < 0) + if (xml_chardata_encode(&encstr, 0, "%s", cv_string_get(cvi)) < 0) goto done; cprintf(cb, "<%s>%s", kname, encstr, kname); free(encstr); @@ -1413,7 +1413,7 @@ xml_find_index_yang(cxobj *xp, goto done; } cvi = cvec_i(cvk, 0); - if (xml_chardata_encode(&encstr, "%s", cv_string_get(cvi)) < 0) + if (xml_chardata_encode(&encstr, 0, "%s", cv_string_get(cvi)) < 0) goto done; cprintf(cb, "<%s>%s", name, encstr, name); free(encstr); @@ -1433,7 +1433,7 @@ xml_find_index_yang(cxobj *xp, yang_flag_get(yi, YANG_FLAG_INDEX) == 0) goto revert; cbuf_reset(cb); - if (xml_chardata_encode(&encstr, "%s", cv_string_get(cvi)) < 0) + if (xml_chardata_encode(&encstr, 0, "%s", cv_string_get(cvi)) < 0) goto done; cprintf(cb, "<%s><%s>%s", name, iname, encstr, iname, name); free(encstr); diff --git a/lib/src/clixon_yang_schema_mount.c b/lib/src/clixon_yang_schema_mount.c index f35fdb76..cd96b155 100644 --- a/lib/src/clixon_yang_schema_mount.c +++ b/lib/src/clixon_yang_schema_mount.c @@ -637,7 +637,7 @@ yang_schema_mount_statistics(clixon_handle h, if (xml2xpath(xmp, NULL, 1, 0, &xpath) < 0) goto done; cprintf(cb, "mountpoint: "); - xml_chardata_cbuf_append(cb, xpath); + xml_chardata_cbuf_append(cb, 0, xpath); cprintf(cb, ""); nr = 0; sz = 0; if (yang_stats(yspec, &nr, &sz) < 0)