1
0
mirror of https://git.openwrt.org/openwrt/openwrt.git synced 2024-06-18 13:13:55 +02:00
openwrt/toolchain/musl/patches/110-read_timezone_from_fs.patch
Rosen Penev aaec2ad13b toolchain/musl: update to 1.2.2
This release introduces 64-bit time_t, which is needed to avoid the
year 2038 problem.

Remove upstream patches. Refreshed others.

Rebased features.h file based on latest musl.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-09-22 19:04:02 +02:00

29 lines
748 B
Diff

--- a/src/time/__tz.c
+++ b/src/time/__tz.c
@@ -31,6 +31,9 @@ static int r0[5], r1[5];
static const unsigned char *zi, *trans, *index, *types, *abbrevs, *abbrevs_end;
static size_t map_size;
+static const char *tzfile;
+static size_t tzfile_size;
+
static char old_tz_buf[32];
static char *old_tz = old_tz_buf;
static size_t old_tz_size = sizeof old_tz_buf;
@@ -132,6 +135,15 @@ static void do_tzset()
"/usr/share/zoneinfo/\0/share/zoneinfo/\0/etc/zoneinfo/\0";
s = getenv("TZ");
+
+ /* if TZ is empty try to read it from /etc/TZ */
+ if (!s || !*s) {
+ if (tzfile)
+ __munmap((void*)tzfile, tzfile_size);
+
+ s = tzfile = (void *)__map_file("/etc/TZ", &tzfile_size);
+ }
+
if (!s) s = "/etc/localtime";
if (!*s) s = __utc;