musl - musl - an implementation of the standard library for Linux-based systems

index : musl
musl - an implementation of the standard library for Linux-based systems
summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2014年06月06日 20:46:05 -0400
committerRich Felker <dalias@aerifal.cx>2014年06月06日 20:46:05 -0400
commitf616294914e7c289791d856dca636bbccad5fef7 (patch)
tree9959d8db03e88546fa7448e28805446c81510c5a /src
parent3ff3a1d541241699f84b52e5ef4bacce2105568f (diff)
downloadmusl-f616294914e7c289791d856dca636bbccad5fef7.tar.gz
use default timezone from /etc/localtime if $TZ is unset/blank
the way this is implemented, it also allows explicit setting of TZ=/etc/localtime even for suid programs. this is not a problem because /etc/localtime is a trusted path, much like the trusted zoneinfo search path.
Diffstat (limited to 'src')
-rw-r--r--src/time/__tz.c 5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/time/__tz.c b/src/time/__tz.c
index 6d7173cf..92c43a57 100644
--- a/src/time/__tz.c
+++ b/src/time/__tz.c
@@ -128,7 +128,7 @@ static void do_tzset()
"/usr/share/zoneinfo/0円/share/zoneinfo/0円/etc/zoneinfo/0円";
s = getenv("TZ");
- if (!s || !*s) s = __gmt;
+ if (!s || !*s) s = "/etc/localtime";
if (old_tz && !strcmp(s, old_tz)) return;
@@ -153,7 +153,8 @@ static void do_tzset()
if (*s == ':' || ((p=strchr(s, '/')) && !memchr(s, ',', p-s))) {
if (*s == ':') s++;
if (*s == '/' || *s == '.') {
- if (!libc.secure) map = __map_file(s, &map_size);
+ if (!libc.secure || !strcmp(s, "/etc/localtime"))
+ map = __map_file(s, &map_size);
} else {
size_t l = strlen(s);
if (l <= NAME_MAX && !strchr(s, '.')) {
generated by cgit v1.2.1 (git 2.18.0) at 2025年10月04日 03:01:47 +0000

AltStyle によって変換されたページ (->オリジナル) /