From c0ab2a2c42af6d2f34a987c7b9903e9737e27a87 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 25 Mar 2023 10:40:19 -0700 Subject: Set close-on-exec when opening fonts.dir & fonts.alias files Signed-off-by: Alan Coopersmith --- src/fontfile/dirfile.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/fontfile/dirfile.c b/src/fontfile/dirfile.c index 04125b5..5155aa5 100644 --- a/src/fontfile/dirfile.c +++ b/src/fontfile/dirfile.c @@ -47,6 +47,10 @@ in this Software without prior written authorization from The Open Group. #include #include "src/util/replace.h" +#ifndef O_CLOEXEC +#define O_CLOEXEC 0 +#endif + static Bool AddFileNameAliases ( FontDirectoryPtr dir ); static int ReadFontAlias ( char *directory, Bool isFile, FontDirectoryPtr *pdir ); @@ -96,7 +100,7 @@ FontFileReadDirectory (const char *directory, FontDirectoryPtr *pdir) strlcat(dir_file, "/", sizeof(dir_file)); strlcat(dir_file, FontDirFile, sizeof(dir_file)); #ifndef WIN32 - file_fd = open(dir_file, O_RDONLY | O_NOFOLLOW); + file_fd = open(dir_file, O_RDONLY | O_NOFOLLOW | O_CLOEXEC); if (file_fd >= 0) { file = fdopen(file_fd, "rt"); } @@ -293,7 +297,7 @@ ReadFontAlias(char *directory, Bool isFile, FontDirectoryPtr *pdir) } #ifndef WIN32 - file_fd = open(alias_file, O_RDONLY | O_NOFOLLOW); + file_fd = open(alias_file, O_RDONLY | O_NOFOLLOW | O_CLOEXEC); if (file_fd >= 0) { file = fdopen(file_fd, "rt"); } -- cgit v1.2.3