mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-06 10:22:07 +00:00
lib: fix segfault on freebsd when using vsnprintf() incorrectly
FreeBSD's libc segfaults when vsnprintf() is called with a null format string. Add a null check before calling vsnprintf() to resolve this problem. Fixes #3537 Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
This commit is contained in:
parent
6205e5dc07
commit
3cb4162cfe
@ -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, ...)
|
int nb_cli_apply_changes(struct vty *vty, const char *xpath_base_fmt, ...)
|
||||||
{
|
{
|
||||||
struct nb_config *candidate_transitory;
|
struct nb_config *candidate_transitory;
|
||||||
char xpath_base[XPATH_MAXLEN];
|
char xpath_base[XPATH_MAXLEN] = {};
|
||||||
va_list ap;
|
|
||||||
bool error = false;
|
bool error = false;
|
||||||
int ret;
|
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);
|
candidate_transitory = nb_config_dup(vty->candidate_config);
|
||||||
|
|
||||||
/* Parse the base XPath format string. */
|
/* Parse the base XPath format string. */
|
||||||
va_start(ap, xpath_base_fmt);
|
if (xpath_base_fmt) {
|
||||||
vsnprintf(xpath_base, sizeof(xpath_base), xpath_base_fmt, ap);
|
va_list ap;
|
||||||
va_end(ap);
|
|
||||||
|
va_start(ap, xpath_base_fmt);
|
||||||
|
vsnprintf(xpath_base, sizeof(xpath_base), xpath_base_fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
/* Edit candidate configuration. */
|
/* Edit candidate configuration. */
|
||||||
for (size_t i = 0; i < vty->num_cfg_changes; i++) {
|
for (size_t i = 0; i < vty->num_cfg_changes; i++) {
|
||||||
|
@ -60,7 +60,7 @@ extern void nb_cli_enqueue_change(struct vty *vty, const char *xpath,
|
|||||||
*
|
*
|
||||||
* xpath_base_fmt
|
* xpath_base_fmt
|
||||||
* Prepend the given XPath (absolute or relative) to all enqueued
|
* Prepend the given XPath (absolute or relative) to all enqueued
|
||||||
* configuration changes.
|
* configuration changes. This is an optional parameter.
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* CMD_SUCCESS on success, CMD_WARNING_CONFIG_FAILED otherwise.
|
* CMD_SUCCESS on success, CMD_WARNING_CONFIG_FAILED otherwise.
|
||||||
|
Loading…
Reference in New Issue
Block a user