diff options
Diffstat (limited to 'lib/log_vty.c')
-rw-r--r-- | lib/log_vty.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/log_vty.c b/lib/log_vty.c index 97026e5db..d46fef15a 100644 --- a/lib/log_vty.c +++ b/lib/log_vty.c @@ -260,10 +260,11 @@ DEFUN_HIDDEN (no_config_log_monitor, static int set_log_file(struct zlog_cfg_file *target, struct vty *vty, const char *fname, int loglevel) { - char *p = NULL; + char path[MAXPATHLEN + 1]; const char *fullpath; bool ok; + /* Path detection. */ if (!IS_DIRECTORY_SEP(*fname)) { char cwd[MAXPATHLEN + 1]; @@ -276,17 +277,14 @@ static int set_log_file(struct zlog_cfg_file *target, struct vty *vty, return CMD_WARNING_CONFIG_FAILED; } - p = XMALLOC(MTYPE_TMP, strlen(cwd) + strlen(fname) + 2); - sprintf(p, "%s/%s", cwd, fname); - fullpath = p; + snprintf(path, sizeof(path), "%s/%s", cwd, fname); + fullpath = path; } else fullpath = fname; target->prio_min = loglevel; ok = zlog_file_set_filename(target, fullpath); - XFREE(MTYPE_TMP, p); - if (!ok) { if (vty) vty_out(vty, "can't open logfile %s\n", fname); |