summaryrefslogtreecommitdiff
path: root/lib/log_vty.c
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@cumulusnetworks.com>2020-04-21 12:56:42 -0400
committerQuentin Young <qlyoung@cumulusnetworks.com>2020-04-21 13:13:06 -0400
commit08808541857dc78edd5bfd70f776bfbe58b44051 (patch)
tree14c77fc316683a098963a0c89084579775373966 /lib/log_vty.c
parent4ced1a2cb310d479915755cb5ced369554895f3a (diff)
pimd, lib: suppress compiler warnings on snprintf
truncation warnings on old compilers Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'lib/log_vty.c')
-rw-r--r--lib/log_vty.c10
1 files changed, 9 insertions, 1 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;