From f25ea40ae190fab5fcbea22abd3694de045701c7 Mon Sep 17 00:00:00 2001 From: Brian Wolfe Date: Mon, 15 Jun 2020 14:16:20 -0700 Subject: [PATCH] timers: use snprintf instead of sprintf --- src/timers.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/timers.cc b/src/timers.cc index 2501bab9..dbc7ba39 100644 --- a/src/timers.cc +++ b/src/timers.cc @@ -213,9 +213,8 @@ std::string LocalDateTimeString() { tz_offset_sign = '-'; } - // Apply % 100 to hour to guarantee range [0, 99]. - tz_len = ::sprintf(tz_offset, "%c%02li:%02li", tz_offset_sign, - (offset_minutes / 100) % 100, offset_minutes % 100); + tz_len = ::snprintf(tz_offset, sizeof(tz_offset), "%c%02li:%02li", + tz_offset_sign, (offset_minutes / 100), offset_minutes % 100); CHECK(tz_len == 6); ((void)tz_len); // Prevent unused variable warning in optimized build. } else {