summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/RdFToBuf.c2
-rw-r--r--src/RdFToI.c6
-rw-r--r--src/WrFFrBuf.c2
-rw-r--r--src/WrFFrI.c2
-rw-r--r--src/XpmI.h7
-rw-r--r--src/rgb.c2
6 files changed, 14 insertions, 7 deletions
diff --git a/src/RdFToBuf.c b/src/RdFToBuf.c
index 1b386f8..4ee9265 100644
--- a/src/RdFToBuf.c
+++ b/src/RdFToBuf.c
@@ -72,7 +72,7 @@ XpmReadFileToBuffer(
*buffer_return = NULL;
#ifndef VAX11C
- fd = open(filename, O_RDONLY);
+ fd = open(filename, O_RDONLY | O_CLOEXEC);
#else
fd = open(filename, O_RDONLY, NULL);
#endif
diff --git a/src/RdFToI.c b/src/RdFToI.c
index a16af88..28c0c33 100644
--- a/src/RdFToI.c
+++ b/src/RdFToI.c
@@ -212,7 +212,7 @@ OpenReadFile(
mdata->stream.file = (stdin);
mdata->type = XPMFILE;
} else {
- int fd = open(filename, O_RDONLY);
+ int fd = open(filename, O_RDONLY | O_CLOEXEC);
#if defined(NO_ZPIPE)
if ( fd < 0 )
return XpmOpenFailed;
@@ -229,11 +229,11 @@ OpenReadFile(
return (XpmNoMemory);
strcpy(compressfile, filename);
strcpy(compressfile + len, ext = ".Z");
- fd = open(compressfile, O_RDONLY);
+ fd = open(compressfile, O_RDONLY | O_CLOEXEC);
if ( fd < 0 )
{
strcpy(compressfile + len, ext = ".gz");
- fd = open(compressfile, O_RDONLY);
+ fd = open(compressfile, O_RDONLY | O_CLOEXEC);
if ( fd < 0 )
{
XpmFree(compressfile);
diff --git a/src/WrFFrBuf.c b/src/WrFFrBuf.c
index 0e57cc8..085b5a8 100644
--- a/src/WrFFrBuf.c
+++ b/src/WrFFrBuf.c
@@ -45,7 +45,7 @@ XpmWriteFileFromBuffer(
char *buffer)
{
size_t fcheck, len;
- FILE *fp = fopen(filename, "w");
+ FILE *fp = fopen(filename, "w" FOPEN_CLOEXEC);
if (!fp)
return XpmOpenFailed;
diff --git a/src/WrFFrI.c b/src/WrFFrI.c
index 234197a..6855c84 100644
--- a/src/WrFFrI.c
+++ b/src/WrFFrI.c
@@ -336,7 +336,7 @@ OpenWriteFile(
#ifndef NO_ZPIPE
size_t len;
#endif
- int fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0644);
+ int fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0644);
if ( fd < 0 )
return(XpmOpenFailed);
#ifndef NO_ZPIPE
diff --git a/src/XpmI.h b/src/XpmI.h
index 70da79e..4ab48f2 100644
--- a/src/XpmI.h
+++ b/src/XpmI.h
@@ -103,6 +103,13 @@ extern FILE *popen();
# endif
#endif
+#ifdef O_CLOEXEC
+# define FOPEN_CLOEXEC "e"
+#else
+# define FOPEN_CLOEXEC ""
+# define O_CLOEXEC 0
+#endif
+
#define XPMMAXCMTLEN BUFSIZ
typedef struct {
unsigned int type;
diff --git a/src/rgb.c b/src/rgb.c
index 5c350eb..de0d17f 100644
--- a/src/rgb.c
+++ b/src/rgb.c
@@ -66,7 +66,7 @@ xpmReadRgbNames(
xpmRgbName *rgb;
/* Open the rgb text file. Abort if error. */
- if ((rgbf = fopen(rgb_fname, "r")) == NULL)
+ if ((rgbf = fopen(rgb_fname, "r" FOPEN_CLOEXEC)) == NULL)
return 0;
/* Loop reading each line in the file. */