]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
pinky: prefer signed types
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 1 Aug 2023 00:51:03 +0000 (17:51 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 1 Aug 2023 00:51:29 +0000 (17:51 -0700)
* 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

index 76da073f660d02c8f04a9c82efa75bad551eb7ad..a284545a563beb16a4e9c976080a5d920930735c 100644 (file)
@@ -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;
 }