Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F102681436
D44754.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D44754.diff
View Options
diff --git a/sys/kern/subr_fattime.c b/sys/kern/subr_fattime.c
--- a/sys/kern/subr_fattime.c
+++ b/sys/kern/subr_fattime.c
@@ -84,6 +84,7 @@
#define YEAR 365 /* Length of normal year */
#define LYC (4 * YEAR + 1) /* Length of 4 year leap-year cycle */
#define T1980 (10 * 365 + 2) /* Days from 1970 to 1980 */
+#define T2108 (138 * 365 + 33) /* Days from 1970 to 2108 */
/* End of month is N days from start of (normal) year */
#define JAN 31
@@ -275,11 +276,17 @@
for (i = 0; i < 10000; i++) {
do {
- ts.tv_sec = random();
- } while (ts.tv_sec < T1980 * 86400);
+ /*
+ * 32-bits gets us to 2106-02-07 06:28:15, but we
+ * need to get to the end of 2107. So, we generate
+ * a 36-bit second count to get us way past 2106.
+ */
+ ts.tv_sec = ((time_t) arc4random() << 4) ^ arc4random();
+ } while ((ts.tv_sec < T1980 * 86400) || (ts.tv_sec >= T2108 * 86400ull));
+
ts.tv_nsec = random() % 1000000000;
- printf("%10d.%03ld -- ", ts.tv_sec, ts.tv_nsec / 1000000);
+ printf("%10jd.%03ld -- ", (intmax_t) ts.tv_sec, ts.tv_nsec / 1000000);
gmtime_r(&ts.tv_sec, &tm);
strftime(buf, sizeof buf, "%Y %m %d %H %M %S", &tm);
@@ -299,7 +306,7 @@
ts.tv_sec = ts.tv_nsec = 0;
fattime2timespec(d, t, p, 1, &ts);
- printf("%10d.%03ld == ", ts.tv_sec, ts.tv_nsec / 1000000);
+ printf("%10jd.%03ld == ", (intmax_t) ts.tv_sec, ts.tv_nsec / 1000000);
gmtime_r(&ts.tv_sec, &tm);
strftime(buf, sizeof buf, "%Y %m %d %H %M %S", &tm);
printf("%s -- ", buf);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 16, 7:16 PM (21 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14663328
Default Alt Text
D44754.diff (1 KB)
Attached To
Mode
D44754: fattime: make the test code check beyond 32-bit time_t limits
Attached
Detach File
Event Timeline
Log In to Comment