summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ICElibint.h6
-rw-r--r--src/authutil.c5
-rw-r--r--src/getauth.c2
3 files changed, 10 insertions, 3 deletions
diff --git a/src/ICElibint.h b/src/ICElibint.h
index 3794085..00c15ca 100644
--- a/src/ICElibint.h
+++ b/src/ICElibint.h
@@ -43,6 +43,12 @@ Author: Ralph Mor, X Consortium
#include <stdlib.h>
#include <stddef.h>
+#ifdef O_CLOEXEC
+#define FOPEN_CLOEXEC "e"
+#else
+#define FOPEN_CLOEXEC ""
+#define O_CLOEXEC 0
+#endif
/*
* Vendor & Release
diff --git a/src/authutil.c b/src/authutil.c
index 86a716b..a47cf46 100644
--- a/src/authutil.c
+++ b/src/authutil.c
@@ -175,7 +175,8 @@ IceLockAuthFile (
{
if (creat_fd == -1)
{
- creat_fd = creat (creat_name, 0666);
+ creat_fd = open (creat_name,
+ O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0666);
if (creat_fd == -1)
{
@@ -347,7 +348,7 @@ IceGetAuthFileEntry (
if (access (filename, R_OK) != 0) /* checks REAL id */
return (NULL);
- if (!(auth_file = fopen (filename, "rb")))
+ if (!(auth_file = fopen (filename, "rb" FOPEN_CLOEXEC)))
return (NULL);
for (;;)
diff --git a/src/getauth.c b/src/getauth.c
index abd5644..b792e3e 100644
--- a/src/getauth.c
+++ b/src/getauth.c
@@ -146,7 +146,7 @@ _IceGetPoValidAuthIndices (
if (access (filename, R_OK) != 0) /* checks REAL id */
return;
- if (!(auth_file = fopen (filename, "rb")))
+ if (!(auth_file = fopen (filename, "rb" FOPEN_CLOEXEC)))
return;
for (;;)