diff options
Diffstat (limited to 'src/MultiSrc.c')
-rw-r--r-- | src/MultiSrc.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/MultiSrc.c b/src/MultiSrc.c index a9e84ba..5544b8b 100644 --- a/src/MultiSrc.c +++ b/src/MultiSrc.c @@ -75,6 +75,10 @@ in this Software without prior written authorization from The Open Group. #include <sys/stat.h> #include <fcntl.h> +#ifndef O_CLOEXEC +#define O_CLOEXEC 0 +#endif + #define MAGIC_VALUE ((XawTextPosition)-1) #define streq(a, b) (strcmp((a), (b)) == 0) @@ -1089,7 +1093,7 @@ WriteToFile(String string, String name) int fd; Bool result = True; - if ((fd = creat(name, 0666)) == -1) + if ((fd = open(name, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0666)) == -1) return (False); if (write(fd, string, strlen(string)) == -1) @@ -1215,7 +1219,7 @@ InitStringOrFile(MultiSrcObject src, Bool newString) XtErrorMsg("NoFile", "multiSourceCreate", "XawError", "Creating a read only disk widget and no file specified.", NULL, 0); - open_mode = O_RDONLY; + open_mode = O_RDONLY | O_CLOEXEC; fdopen_mode = "r"; break; case XawtextAppend: @@ -1225,9 +1229,9 @@ InitStringOrFile(MultiSrcObject src, Bool newString) src->multi_src.is_tempfile = True; } else { -/* O_NOFOLLOW is a BSD & Linux extension */ +/* O_NOFOLLOW was a FreeBSD & Linux extension, now adopted by POSIX */ #ifdef O_NOFOLLOW - open_mode = O_RDWR | O_NOFOLLOW; + open_mode = O_RDWR | O_NOFOLLOW | O_CLOEXEC; #else open_mode = O_RDWR; /* unsafe; subject to race conditions */ #endif |