diff options
| author | Quentin Young <qlyoung@cumulusnetworks.com> | 2020-04-21 12:56:42 -0400 | 
|---|---|---|
| committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2020-04-21 13:13:06 -0400 | 
| commit | 08808541857dc78edd5bfd70f776bfbe58b44051 (patch) | |
| tree | 14c77fc316683a098963a0c89084579775373966 | |
| parent | 4ced1a2cb310d479915755cb5ced369554895f3a (diff) | |
pimd, lib: suppress compiler warnings on snprintf
truncation warnings on old compilers
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
| -rw-r--r-- | lib/log_vty.c | 10 | ||||
| -rw-r--r-- | pimd/pim_cmd.c | 2 | 
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/log_vty.c b/lib/log_vty.c index d46fef15ae..d1dcac2340 100644 --- a/lib/log_vty.c +++ b/lib/log_vty.c @@ -277,7 +277,15 @@ static int set_log_file(struct zlog_cfg_file *target, struct vty *vty,  			return CMD_WARNING_CONFIG_FAILED;  		} -		snprintf(path, sizeof(path), "%s/%s", cwd, fname); +		int pr = snprintf(path, sizeof(path), "%s/%s", cwd, fname); +		if (pr < 0 || (unsigned int)pr >= sizeof(path)) { +			flog_err_sys( +				EC_LIB_SYSTEM_CALL, +				"%s: Path too long ('%s/%s'); system maximum is %u", +				__func__, cwd, fname, MAXPATHLEN); +			return CMD_WARNING_CONFIG_FAILED; +		} +  		fullpath = path;  	} else  		fullpath = fname; diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index cdda7c03aa..7f75660011 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -2510,8 +2510,8 @@ static void pim_show_upstream(struct pim_instance *pim, struct vty *vty,  		pim_upstream_state2brief_str(up->join_state, state_str, sizeof(state_str));  		if (up->reg_state != PIM_REG_NOINFO) {  			char tmp_str[PIM_REG_STATE_STR_LEN]; +			char tmp[sizeof(state_str) + 1]; -			char tmp[sizeof(state_str)];  			snprintf(tmp, sizeof(tmp), ",%s",  				 pim_reg_state2brief_str(up->reg_state, tmp_str,  							 sizeof(tmp_str)));  | 
