]> git.puffer.fish Git - matthieu/frr.git/commitdiff
pimd, lib: suppress compiler warnings on snprintf
authorQuentin Young <qlyoung@cumulusnetworks.com>
Tue, 21 Apr 2020 16:56:42 +0000 (12:56 -0400)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Tue, 21 Apr 2020 17:13:06 +0000 (13:13 -0400)
truncation warnings on old compilers

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
lib/log_vty.c
pimd/pim_cmd.c

index d46fef15aee0ce4cbc33388b86ec03b3b02f5e41..d1dcac23401203d523ec790d15ed0018863df28e 100644 (file)
@@ -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;
index cdda7c03aa7559bf8f8f94d52b26fd00fe7d8b48..7f756600110d094b3b8e04440243eb293fc954d7 100644 (file)
@@ -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)));