Annotation of /trunk/busybox/patches/busybox-1.22.1-date.patch
Parent Directory | Revision Log
Revision 2376 -
(hide annotations)
(download)
Tue Jan 21 12:07:18 2014 UTC (10 years, 8 months ago) by niro
File size: 1008 byte(s)
Tue Jan 21 12:07:18 2014 UTC (10 years, 8 months ago) by niro
File size: 1008 byte(s)
-added upstream patches
1 | niro | 2376 | --- busybox-1.22.1/libbb/time.c |
2 | +++ busybox-1.22.1-date/libbb/time.c | ||
3 | @@ -68,15 +68,23 @@ void FAST_FUNC parse_datestr(const char | ||
4 | /* else end != NUL and we error out */ | ||
5 | } | ||
6 | } else | ||
7 | - /* yyyy-mm-dd HH */ | ||
8 | - if (sscanf(date_str, "%u-%u-%u %u%c", &ptm->tm_year, | ||
9 | + if (strchr(date_str, '-') | ||
10 | + /* Why strchr('-') check? | ||
11 | + * sscanf below will trash ptm->tm_year, this breaks | ||
12 | + * if parse_str is "10101010" (iow, "MMddhhmm" form) | ||
13 | + * because we destroy year. Do these sscanf | ||
14 | + * only if we saw a dash in parse_str. | ||
15 | + */ | ||
16 | + /* yyyy-mm-dd HH */ | ||
17 | + && (sscanf(date_str, "%u-%u-%u %u%c", &ptm->tm_year, | ||
18 | &ptm->tm_mon, &ptm->tm_mday, | ||
19 | &ptm->tm_hour, | ||
20 | &end) >= 4 | ||
21 | - /* yyyy-mm-dd */ | ||
22 | - || sscanf(date_str, "%u-%u-%u%c", &ptm->tm_year, | ||
23 | + /* yyyy-mm-dd */ | ||
24 | + || sscanf(date_str, "%u-%u-%u%c", &ptm->tm_year, | ||
25 | &ptm->tm_mon, &ptm->tm_mday, | ||
26 | &end) >= 3 | ||
27 | + ) | ||
28 | ) { | ||
29 | ptm->tm_year -= 1900; /* Adjust years */ | ||
30 | ptm->tm_mon -= 1; /* Adjust month from 1-12 to 0-11 */ |