From 5ec8965d187febec9eeb3b9b17ecf1f0ce7a8cd8 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Mon, 22 Mar 2021 12:16:52 +0100 Subject: [PATCH] Fixed: [backend start resconf failed due to path string truncated #192](https://github.com/clicon/clixon/issues/192) --- CHANGELOG.md | 1 + apps/backend/backend_plugin_restconf.c | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a76fabb..7b613db1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -70,6 +70,7 @@ Developers may need to change their code ### Corrected Bugs +* Fixed: [backend start resconf failed due to path string truncated #192](https://github.com/clicon/clixon/issues/192) * Fixed: [state showing error in cli with CLICON_STREAM_DISCOVERY_RFC8040 #191](https://github.com/clicon/clixon/issues/191) * Fixed: [yang submodule show error in modules-state #190](yang submodule show error in modules-state #190) * Fixed: [Backend can not read datastore with container named "config" #147](https://github.com/clicon/clixon/issues/147) diff --git a/apps/backend/backend_plugin_restconf.c b/apps/backend/backend_plugin_restconf.c index 8dd67a26..97227ba7 100644 --- a/apps/backend/backend_plugin_restconf.c +++ b/apps/backend/backend_plugin_restconf.c @@ -111,8 +111,7 @@ restconf_pseudo_process_control(clicon_handle h) char **argv = NULL; int i; int nr; - char dbgstr[8]; - char wwwstr[64]; + cbuf *cb = NULL; nr = 4; if (clicon_debug_get() != 0) @@ -122,8 +121,12 @@ restconf_pseudo_process_control(clicon_handle h) goto done; } i = 0; - snprintf(wwwstr, sizeof(wwwstr)-1, "%s/clixon_restconf", clicon_option_str(h, "CLICON_WWWDIR")); - argv[i++] = wwwstr; + if ((cb = cbuf_new()) == NULL){ + clicon_err(OE_UNIX, errno, "cbuf_new"); + goto done; + } + cprintf(cb, "%s/clixon_restconf", clicon_option_str(h, "CLICON_WWWDIR")); + argv[i++] = cbuf_get(cb); argv[i++] = "-f"; argv[i++] = clicon_option_str(h, "CLICON_CONFIGFILE"); /* Add debug if backend has debug. @@ -131,8 +134,9 @@ restconf_pseudo_process_control(clicon_handle h) */ if (clicon_debug_get() != 0){ argv[i++] = "-D"; - snprintf(dbgstr, sizeof(dbgstr)-1, "%d", clicon_debug_get()); - argv[i++] = dbgstr; + cbuf_reset(cb); + cprintf(cb, "%d", clicon_debug_get()); + argv[i++] = cbuf_get(cb); } argv[i++] = NULL; assert(i==nr); @@ -146,6 +150,8 @@ restconf_pseudo_process_control(clicon_handle h) free(argv); retval = 0; done: + if (cb) + cbuf_free(cb); return retval; }