odhcpd: Fix a segfault in DHCPv6 option handling
[openwrt/staging/chunkeey.git] / package / utils / busybox / patches / 003-upstream_date_fix.patch
1 --- a/libbb/time.c
2 +++ b/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 */