summaryrefslogtreecommitdiff
path: root/gmodule
diff options
context:
space:
mode:
authorMaciej S. Szmigiero <maciej.szmigiero@oracle.com>2023-02-19 16:22:22 +0100
committerPhilip Withnall <pwithnall@endlessos.org>2023-02-21 12:42:55 +0000
commit3f2e18b07c24686bd7d67839daac3566d634243d (patch)
tree3334c93f99971488fa7982d1227ee8c4b569b277 /gmodule
parent0f5d2748719627fafbdcfd67a776002cd6ffae81 (diff)
downloadglib-3f2e18b07c24686bd7d67839daac3566d634243d.tar.gz
Use O_CLOEXEC in {g_,}open () calls for race-free setting of the close-on-exec flag
The remaining call sites are either Windows-only, between fork () and exec () or in xdgmime copylib. Hope I haven't missed any site.
Diffstat (limited to 'gmodule')
-rw-r--r--gmodule/gmodule.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/gmodule/gmodule.c b/gmodule/gmodule.c
index 00a2c055f..aafaaf0ad 100644
--- a/gmodule/gmodule.c
+++ b/gmodule/gmodule.c
@@ -45,6 +45,10 @@
#include <io.h> /* For open() and close() prototypes. */
#endif
+#ifndef O_CLOEXEC
+#define O_CLOEXEC 0
+#endif
+
#include "gmoduleconf.h"
#include "gstdio.h"
@@ -388,7 +392,7 @@ parse_libtool_archive (const gchar* libtool_name)
GTokenType token;
GScanner *scanner;
- int fd = g_open (libtool_name, O_RDONLY, 0);
+ int fd = g_open (libtool_name, O_RDONLY | O_CLOEXEC, 0);
if (fd < 0)
{
gchar *display_libtool_name = g_filename_display_name (libtool_name);