summaryrefslogtreecommitdiff
path: root/lib/northbound_cli.c
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@users.noreply.github.com>2019-01-03 11:48:31 -0500
committerGitHub <noreply@github.com>2019-01-03 11:48:31 -0500
commitc05f659a58466dd1a8dfe2a2ebbefeeb0b9c8ee0 (patch)
tree8d0c3ceba1bb3561caa54abe86a6b21d58f923b1 /lib/northbound_cli.c
parentcb6aafaccccbe7f132def2eaee5cde7a91667216 (diff)
parent3cb4162cfe6d18a07a15d8c35284d0563dcfff67 (diff)
Merge pull request #3561 from opensourcerouting/northbound-freebsd-fix
lib: fix segfault on freebsd when using vsnprintf() incorrectly
Diffstat (limited to 'lib/northbound_cli.c')
-rw-r--r--lib/northbound_cli.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/northbound_cli.c b/lib/northbound_cli.c
index acde0ead02..2b024ace93 100644
--- a/lib/northbound_cli.c
+++ b/lib/northbound_cli.c
@@ -79,8 +79,7 @@ void nb_cli_enqueue_change(struct vty *vty, const char *xpath,
int nb_cli_apply_changes(struct vty *vty, const char *xpath_base_fmt, ...)
{
struct nb_config *candidate_transitory;
- char xpath_base[XPATH_MAXLEN];
- va_list ap;
+ char xpath_base[XPATH_MAXLEN] = {};
bool error = false;
int ret;
@@ -94,9 +93,13 @@ int nb_cli_apply_changes(struct vty *vty, const char *xpath_base_fmt, ...)
candidate_transitory = nb_config_dup(vty->candidate_config);
/* Parse the base XPath format string. */
- va_start(ap, xpath_base_fmt);
- vsnprintf(xpath_base, sizeof(xpath_base), xpath_base_fmt, ap);
- va_end(ap);
+ if (xpath_base_fmt) {
+ va_list ap;
+
+ va_start(ap, xpath_base_fmt);
+ vsnprintf(xpath_base, sizeof(xpath_base), xpath_base_fmt, ap);
+ va_end(ap);
+ }
/* Edit candidate configuration. */
for (size_t i = 0; i < vty->num_cfg_changes; i++) {