aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>2025-09-29 11:48:02 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>2025-09-29 11:57:32 +0000
commitd28e4ce6cb61916b4f6bedcf4205a4da1ae121e1 (patch)
tree334ca461d35829f2a71665c3537ec7585c8791c8
parent69ede18b950e32317d7741410cde7543fa0fce3c (diff)
tzcode: Tweak open flags.
Upstream uses a set of flags that reduces to O_RDONLY | O_CLOEXEC when you ignore flags that either don't exist in FreeBSD or have no effect. We were using O_RDONLY | O_BINARY, which reduces to O_RDONLY. Add O_CLOEXEC. Also replace O_RDONLY with the more accurate O_SEARCH when opening TZDIR. MFC after: 3 days Fixes: 967a49a21a27 ("Update tzcode to 2025b")
-rw-r--r--contrib/tzcode/localtime.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/contrib/tzcode/localtime.c b/contrib/tzcode/localtime.c
index 8638ac9ba2cd..1668475ea646 100644
--- a/contrib/tzcode/localtime.c
+++ b/contrib/tzcode/localtime.c
@@ -677,7 +677,7 @@ tzloadbody(char const *name, struct state *sp, char tzloadflags,
while (*relname == '/')
relname++;
}
- dd = open(TZDIR, O_DIRECTORY | O_RDONLY);
+ dd = open(TZDIR, O_DIRECTORY | O_SEARCH | O_CLOEXEC);
if ((tzloadflags & TZLOAD_FROMENV) && issetugid()) {
if (dd < 0)
return errno;
@@ -687,14 +687,14 @@ tzloadbody(char const *name, struct state *sp, char tzloadflags,
fid = -1;
errno = EINVAL;
} else {
- fid = openat(dd, relname, O_RDONLY | O_BINARY, AT_RESOLVE_BENEATH);
+ fid = openat(dd, relname, O_RDONLY | O_CLOEXEC | O_RESOLVE_BENEATH);
}
} else {
if (dd < 0) {
relname = name;
dd = AT_FDCWD;
}
- fid = openat(dd, relname, O_RDONLY | O_BINARY, 0);
+ fid = openat(dd, relname, O_RDONLY | O_CLOEXEC);
}
if (dd != AT_FDCWD && dd >= 0) {
serrno = errno;