summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2023-03-25 10:40:19 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2023-03-25 10:40:19 -0700
commitc0ab2a2c42af6d2f34a987c7b9903e9737e27a87 (patch)
tree430247357e12ffb26b9d2ac82998a6853c16b9f5 /src
parenta5ee0e9ab968d795fdb9983457a9b7d16ed249ef (diff)
Set close-on-exec when opening fonts.dir & fonts.alias files
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'src')
-rw-r--r--src/fontfile/dirfile.c8
1 files 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 <limits.h>
#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");
}