diff options
| author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2025-09-28 11:11:26 +0000 |
|---|---|---|
| committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2025-09-28 11:12:44 +0000 |
| commit | 202b59c35ead5bd2b71331169bdeb4845cb655c1 (patch) | |
| tree | 8c4f215e08779505b468aa7ff677452eaf0d1d07 | |
| parent | 5c8835e5c0ce34ee50eba92bb5f4de36139ae7ea (diff) | |
tzcode: Really fix issues when TZ is an absolute path
This was accidentally left out of the previous commit.
Fixes: df8bc705eb04 ("tzcode: Fix issues when TZ is an absolute path")
| -rw-r--r-- | contrib/tzcode/localtime.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/contrib/tzcode/localtime.c b/contrib/tzcode/localtime.c index c98134f7be7c..8638ac9ba2cd 100644 --- a/contrib/tzcode/localtime.c +++ b/contrib/tzcode/localtime.c @@ -672,13 +672,16 @@ tzloadbody(char const *name, struct state *sp, char tzloadflags, if ((tzloadflags & TZLOAD_FROMENV) && strcmp(name, TZDEFAULT) == 0) tzloadflags &= ~TZLOAD_FROMENV; relname = name; - if (strncmp(relname, TZDIR "/", strlen(TZDIR) + 1) == 0) + if (strncmp(relname, TZDIR "/", strlen(TZDIR) + 1) == 0) { relname += strlen(TZDIR) + 1; + while (*relname == '/') + relname++; + } dd = open(TZDIR, O_DIRECTORY | O_RDONLY); if ((tzloadflags & TZLOAD_FROMENV) && issetugid()) { if (dd < 0) return errno; - if (fstatat(dd, name, &sb, AT_RESOLVE_BENEATH) < 0) { + if (fstatat(dd, relname, &sb, AT_RESOLVE_BENEATH) < 0) { fid = -1; } else if (!S_ISREG(sb.st_mode)) { fid = -1; |
