diff options
| author | Quentin Young <qlyoung@cumulusnetworks.com> | 2020-04-20 17:59:31 -0400 | 
|---|---|---|
| committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2020-04-20 19:14:33 -0400 | 
| commit | fc746f1c01daf34600d83293647199e81fcb8316 (patch) | |
| tree | f26168f502d6b5faaffff8c7945acbb88c885fa1 /lib/log_vty.c | |
| parent | 772270f3b6a37a2dd9432541cce436e9b45bb6b9 (diff) | |
*: manually remove some more sprintf
Take care of some more complicated cases by hand
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
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 97026e5dbc..d46fef15ae 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);  | 
