aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristos Zoulas <christos@NetBSD.org>2015-02-25 21:39:30 +0100
committerMike DePaulo <mikedep333@gmail.com>2015-03-28 09:15:31 -0400
commit6bbd73827f301fbe93b96649b63355c2ee4b0b80 (patch)
treebac3befa086ec40b1df4ec7fc84f76b7b11c582c
parent9df762ae9448939d7b5a63a528313b6ea297dd65 (diff)
downloadvcxsrv-6bbd73827f301fbe93b96649b63355c2ee4b0b80.tar.gz
vcxsrv-6bbd73827f301fbe93b96649b63355c2ee4b0b80.tar.bz2
vcxsrv-6bbd73827f301fbe93b96649b63355c2ee4b0b80.zip
Set close-on-exec for font file I/O.
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Signed-off-by: Thomas Klausner <wiz@NetBSD.org> (cherry picked from commit d9fda3d247942292a5f24694c22337c547006e11)
-rw-r--r--libXfont/src/fontfile/fileio.c5
-rw-r--r--libXfont/src/fontfile/filewr.c12
2 files changed, 11 insertions, 6 deletions
diff --git a/libXfont/src/fontfile/fileio.c b/libXfont/src/fontfile/fileio.c
index 80af51193..d44cecdc4 100644
--- a/libXfont/src/fontfile/fileio.c
+++ b/libXfont/src/fontfile/fileio.c
@@ -36,6 +36,9 @@ in this Software without prior written authorization from The Open Group.
#ifndef O_BINARY
#define O_BINARY O_RDONLY
#endif
+#ifndef O_CLOEXEC
+#define O_CLOEXEC 0
+#endif
FontFilePtr
FontFileOpen (const char *name)
@@ -44,7 +47,7 @@ FontFileOpen (const char *name)
int len;
BufFilePtr raw, cooked;
- fd = open (name, O_BINARY);
+ fd = open (name, O_BINARY|O_CLOEXEC);
if (fd < 0)
return 0;
raw = BufFileOpenRead (fd);
diff --git a/libXfont/src/fontfile/filewr.c b/libXfont/src/fontfile/filewr.c
index bcc7b1eda..859a0bec1 100644
--- a/libXfont/src/fontfile/filewr.c
+++ b/libXfont/src/fontfile/filewr.c
@@ -33,17 +33,19 @@ in this Software without prior written authorization from The Open Group.
#endif
#include <X11/fonts/fntfilio.h>
#include <X11/Xos.h>
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+#ifndef O_CLOEXEC
+#define O_CLOEXEC 0
+#endif
FontFilePtr
FontFileOpenWrite (const char *name)
{
int fd;
-#if defined(WIN32) || defined(__CYGWIN__)
- fd = open (name, O_CREAT|O_TRUNC|O_RDWR|O_BINARY, 0666);
-#else
- fd = creat (name, 0666);
-#endif
+ fd = open (name, O_CREAT|O_TRUNC|O_RDWR|O_BINARY|O_CLOEXEC, 0666);
if (fd < 0)
return 0;
return (FontFilePtr) BufFileOpenWrite (fd);