]> git.proxmox.com Git - mirror_frr.git/blobdiff - vtysh/vtysh_main.c
lib: fix segfault on freebsd when using vsnprintf() incorrectly
[mirror_frr.git] / vtysh / vtysh_main.c
index 7d882620e8d62a336ebaea5847b6a444c2fda91b..2e4510a45a876be3442567017e82e3e6bf356ad9 100644 (file)
 #include <readline/readline.h>
 #include <readline/history.h>
 
+/*
+ * The append_history function only appears in newer versions
+ * of the readline library it appears like.  Since we don't
+ * need this just silently ignore the code on these
+ * ancient platforms.
+ */
+#if !defined HAVE_APPEND_HISTORY
+#define append_history(A, B)
+#endif
+
 #include <lib/version.h>
 #include "getopt.h"
 #include "command.h"
@@ -356,7 +366,7 @@ int main(int argc, char **argv, char **env)
                        break;
                case OPTION_CONFDIR:
                        ditch_suid = 1; /* option disables SUID */
-                       strlcpy(sysconfdir, optarg, sizeof(sysconfdir));
+                       snprintf(sysconfdir, sizeof(sysconfdir), "%s/", optarg);
                        break;
                case 'N':
                        if (strchr(optarg, '/') || strchr(optarg, '.')) {
@@ -586,7 +596,6 @@ int main(int argc, char **argv, char **env)
                        vtysh_execute("enable");
 
                while (cmd != NULL) {
-                       int ret;
                        char *eol;
 
                        while ((eol = strchr(cmd->line, '\n')) != NULL) {
@@ -652,7 +661,7 @@ int main(int argc, char **argv, char **env)
        /* Boot startup configuration file. */
        if (boot_flag) {
                vtysh_flock_config(frr_config);
-               int ret = vtysh_read_config(frr_config);
+               ret = vtysh_read_config(frr_config);
                vtysh_unflock_config();
                if (ret) {
                        fprintf(stderr,
@@ -666,8 +675,6 @@ int main(int argc, char **argv, char **env)
                        exit(0);
        }
 
-       vtysh_pager_init();
-
        vtysh_readline_init();
 
        vty_hello(vty);