Fixed issue https://github.com/clicon/clixon/issues/17 special character in strings can break RPCs

This commit is contained in:
Olof hagsand 2018-04-21 16:32:46 +02:00
parent 7650803475
commit 67c0abead7
15 changed files with 405 additions and 136 deletions

View file

@ -1083,12 +1083,12 @@ from_client_msg(clicon_handle h,
goto done;
}
if (clicon_msg_decode(msg, &xt) < 0){
if (netconf_malformed_message(cbret, "Not recognized, rpc expected")< 0)
if (netconf_malformed_message(cbret, "XML parse error")< 0)
goto done;
goto reply;
}
if ((x = xpath_first(xt, "/rpc")) == NULL){
if (netconf_malformed_message(cbret, "Not recognized, rpc expected")< 0)
if (netconf_malformed_message(cbret, "rpc keyword expected")< 0)
goto done;
goto reply;
}
@ -1187,6 +1187,8 @@ from_client_msg(clicon_handle h,
if (netconf_operation_failed(cbret, "application", clicon_err_reason)< 0)
goto done;
clicon_debug(1, "%s cbret:%s", __FUNCTION__, cbuf_get(cbret));
/* XXX problem here is that cbret has not been parsed so may contain
parse errors */
if (send_msg_reply(ce->ce_s, cbuf_get(cbret), cbuf_len(cbret)+1) < 0){
switch (errno){
case EPIPE:

View file

@ -516,12 +516,12 @@ cli_show_config(clicon_handle h,
xml2txt(stdout, xc, 0); /* tree-formed text */
break;
case FORMAT_CLI:
/* get CLI generatade mode: VARS|ALL */
if ((gt = clicon_cli_genmodel_type(h)) == GT_ERR)
goto done;
xc = NULL; /* Dont print xt itself */
while ((xc = xml_child_each(xt, xc, -1)) != NULL){
if ((gt = clicon_cli_genmodel_type(h)) == GT_ERR)
goto done;
while ((xc = xml_child_each(xt, xc, -1)) != NULL)
xml2cli(stdout, xc, NULL, gt); /* cli syntax */
}
break;
case FORMAT_NETCONF:
fprintf(stdout, "<rpc><edit-config><target><candidate/></target><config>\n");