We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c0eabfd commit 8ff9937Copy full SHA for 8ff9937
src/libc/asctime.c
@@ -14,7 +14,19 @@ char *asctime(const struct tm *timeptr)
14
};
15
static char result[26];
16
17
- sprintf(result, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
+ if (!timeptr ||
18
+ timeptr->tm_wday < 0 || timeptr->tm_wday > 6 ||
19
+ timeptr->tm_mon < 0 || timeptr->tm_mon > 11 ||
20
+ timeptr->tm_mday < 1 || timeptr->tm_mday > 31 ||
21
+ timeptr->tm_hour < 0 || timeptr->tm_hour > 23 ||
22
+ timeptr->tm_min < 0 || timeptr->tm_min > 59 ||
23
+ timeptr->tm_sec < 0 || timeptr->tm_sec > 60 ||
24
+ timeptr->tm_year < -1900 || timeptr->tm_year > 8099)
25
+ {
26
+ return NULL;
27
+ }
28
+
29
+ sprintf(result, "%.3s %.3s %2d %.2d:%.2d:%.2d %d\n",
30
wday_name[timeptr->tm_wday],
31
mon_name[timeptr->tm_mon],
32
timeptr->tm_mday,
0 commit comments