From: Paul Eggert Date: Tue, 1 Aug 2023 00:51:03 +0000 (-0700) Subject: pinky: prefer signed types X-Git-Tag: v9.4~48 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0b2796750ff68eb58616655236d7003f6d30223a;p=thirdparty%2Fcoreutils.git pinky: prefer signed types * 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...). --- 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; }