From 0b2796750ff68eb58616655236d7003f6d30223a Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 31 Jul 2023 17:51:03 -0700 Subject: [PATCH] pinky: prefer signed types MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * src/pinky.c (idle_string): Prefer intmax_t to unsigned long int; this avoids an overflow on platforms where unsigned long is 32 bits and time_t is 64 bits (the bug could occur on such a system that was idle for more than 6 million years, so it’s a bit hard to supply a test case...). --- src/pinky.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pinky.c b/src/pinky.c index 76da073f66..a284545a56 100644 --- a/src/pinky.c +++ b/src/pinky.c @@ -164,8 +164,8 @@ idle_string (time_t when) } else { - unsigned long int days = seconds_idle / (24 * 60 * 60); - sprintf (buf, "%lud", days); + intmax_t days = seconds_idle / (24 * 60 * 60); + sprintf (buf, "%"PRIdMAX, days); } return buf; } -- 2.47.2