From 2408433404732b146bf41a2451d23ffadad5a816 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Tue, 28 Mar 2023 11:55:59 -0700 Subject: Set close-on-exec when opening files Signed-off-by: Alan Coopersmith --- src/encparse.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/encparse.c b/src/encparse.c index 7c29628..bf9ea23 100644 --- a/src/encparse.c +++ b/src/encparse.c @@ -37,6 +37,14 @@ THE SOFTWARE. #include +#include +#ifdef O_CLOEXEC +#define FOPEN_CLOEXEC "e" +#else +#define FOPEN_CLOEXEC "" +#endif + + #include "zlib.h" typedef gzFile FontFilePtr; @@ -889,7 +897,7 @@ FontEncReallyReallyLoad(const char *charset, /* As we don't really expect to open encodings that often, we don't take the trouble of caching encodings directories. */ - if ((file = fopen(dirname, "r")) == NULL) { + if ((file = fopen(dirname, "r" FOPEN_CLOEXEC)) == NULL) { return NULL; } -- cgit v1.2.3