Cygwin: strptime: add release note
[newlib-cygwin.git] / winsup / cygwin / tzcode / localtime.c.patch
blob0587b5ea7626b605849911c2efa2071e50795d26
1 --- localtime.c 2020-05-16 21:54:00.533111800 -0700
2 +++ localtime.c.patched 2020-05-22 00:03:30.826646000 -0700
3 @@ -413,7 +413,7 @@
4 };
6 /* TZDIR with a trailing '/' rather than a trailing '\0'. */
7 -static char const tzdirslash[sizeof TZDIR] = TZDIR "/";
8 +static char const tzdirslash[sizeof TZDIR + 1] = TZDIR "/";
10 /* Local storage needed for 'tzloadbody'. */
11 union local_storage {
12 @@ -473,7 +473,7 @@
13 would pull in stdio (and would fail if the
14 resulting string length exceeded INT_MAX!). */
15 memcpy(lsp->fullname, tzdirslash, sizeof tzdirslash);
16 - strcpy(lsp->fullname + sizeof tzdirslash, name);
17 + strcpy(lsp->fullname + sizeof tzdirslash - 1, name);
19 /* Set doaccess if NAME contains a ".." file name
20 component, as such a name could read a file outside
21 @@ -488,11 +488,11 @@
22 name = lsp->fullname;
24 if (doaccess && access(name, R_OK) != 0)
25 - return errno;
26 + goto trydefrules;
28 fid = open(name, OPEN_MODE);
29 if (fid < 0)
30 - return errno;
31 + goto trydefrules;
32 nread = read(fid, up->buf, sizeof up->buf);
33 if (nread < (ssize_t)tzheadsize) {
34 int err = nread < 0 ? errno : EINVAL;
35 @@ -501,6 +501,17 @@
37 if (close(fid) < 0)
38 return errno;
39 + if (0) {
40 + const char *base;
41 +trydefrules:
43 + base = strrchr(name, '/');
44 + base = base ? base + 1 : name;
45 + if (strcmp(base, TZDEFRULES))
46 + return errno;
47 + nread = sizeof _posixrules_data;
48 + memcpy(up->buf, _posixrules_data, nread);
49 + }
50 for (stored = 4; stored <= 8; stored *= 2) {
51 int_fast32_t ttisstdcnt = detzcode(up->tzhead.tzh_ttisstdcnt);
52 int_fast32_t ttisutcnt = detzcode(up->tzhead.tzh_ttisutcnt);
53 @@ -1417,6 +1428,8 @@
54 tzsetlcl(char const *name)
56 struct state *sp = __lclptr;
57 + if (! name)
58 + name = tzgetwintzi(__UNCONST(wildabbr), (char *) alloca (512));
59 int lcl = name ? strlen(name) < sizeof lcl_TZname : -1;
60 if (lcl < 0 ? lcl_is_set < 0
61 : 0 < lcl_is_set && strcmp(lcl_TZname, name) == 0)