stat: negative %X/%Y/%Z timestamps after Y2038 on 32-bit time64 build
Theo GAIGE via busybox <[email protected]>
| Newsgroups | gmane.linux.busybox |
|---|---|
| Message-ID | <AS4SPRMB00514E2C08FADB0DAE702F70CEDC2@AS4SPRMB0051.EURP192.PROD.OUTLOOK.COM> |
While testing a 32-bit system with the clock set beyond the Y2038 boundary, I noticed that the timestamps printed by `stat` are negative when using the `%X`, `%Y`, and `%Z` format specifiers, even though the human-readable timestamps printed by the same command appear correct. I used BusyBox 1.38.0 compiled with glibc 2.43 and the `-D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64` compiler flags. I was able to reproduce this on another 32-bit platform. Reproducer: ``` $ date -s "@2147483668" Tue Jan 19 03:14:28 UTC 2038 $ touch /tmp/test-bug-2038.tmp $ stat /tmp/test-bug-2038.tmp File: /tmp/test-bug-2038.tmp Size: 0 Blocks: 0 IO Block: 4096 regular empty file Device: 16h/22d Inode: 8 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2038-01-19 03:14:42.390000000 +0000 Modify: 2038-01-19 03:14:42.390000000 +0000 Change: 2038-01-19 03:14:42.390000000 +0000 $ stat -c '%X %Y %Z' /tmp/test-bug-2038.tmp -2147483614 -2147483614 -2147483614 ``` The formatted timestamps appear correct, but the values returned by `%X`, `%Y`, and `%Z` look as if they have wrapped to signed 32-bit integers. Can anyone else reproduce this issue? If so, is this a known BusyBox limitation or a bug in the stat implementation? Best Regards, Théo _______________________________________________ busybox mailing list [email protected] https://lists.busybox.net/mailman/listinfo/busybox