summaryrefslogtreecommitdiffstats
path: root/ldpd
diff options
context:
space:
mode:
authorRafael Zalamena <rzalamena@opensourcerouting.org>2023-01-19 16:21:27 +0100
committerRafael Zalamena <rzalamena@opensourcerouting.org>2023-01-20 19:40:24 +0100
commitb6ee94b5b1f0a0652455264fa62a92ed5abbf855 (patch)
tree7e293340fb880323754cd39ebf236ba9703b05cb /ldpd
parentpimd: fix mtracebis tool warning (diff)
downloadfrr-b6ee94b5b1f0a0652455264fa62a92ed5abbf855.tar.xz
frr-b6ee94b5b1f0a0652455264fa62a92ed5abbf855.zip
ldpd: fix time truncation
Use bigger storage for handling time variables so we don't truncate. Found by Coverity Scan (CID 1519735) Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
Diffstat (limited to 'ldpd')
-rw-r--r--ldpd/logmsg.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/ldpd/logmsg.c b/ldpd/logmsg.c
index ff9294f9d..e16006b89 100644
--- a/ldpd/logmsg.c
+++ b/ldpd/logmsg.c
@@ -137,7 +137,7 @@ log_time(time_t t)
char *buf;
static char tfbuf[TF_BUFS][TF_LEN]; /* ring buffer */
static int idx = 0;
- unsigned int sec, min, hrs, day, week;
+ uint64_t sec, min, hrs, day, week;
buf = tfbuf[idx++];
if (idx == TF_BUFS)
@@ -155,11 +155,17 @@ log_time(time_t t)
week /= 7;
if (week > 0)
- snprintf(buf, TF_LEN, "%02uw%01ud%02uh", week, day, hrs);
+ snprintfrr(buf, TF_LEN,
+ "%02" PRIu64 "w%01" PRIu64 "d%02" PRIu64 "h", week,
+ day, hrs);
else if (day > 0)
- snprintf(buf, TF_LEN, "%01ud%02uh%02um", day, hrs, min);
+ snprintfrr(buf, TF_LEN,
+ "%01" PRIu64 "d%02" PRIu64 "h%02" PRIu64 "m", day,
+ hrs, min);
else
- snprintf(buf, TF_LEN, "%02u:%02u:%02u", hrs, min, sec);
+ snprintfrr(buf, TF_LEN,
+ "%02" PRIu64 ":%02" PRIu64 ":%02" PRIu64, hrs, min,
+ sec);
return (buf);
}