diff options
author | Maciej S. Szmigiero <maciej.szmigiero@oracle.com> | 2023-02-19 16:22:22 +0100 |
---|---|---|
committer | Philip Withnall <pwithnall@endlessos.org> | 2023-02-21 12:42:55 +0000 |
commit | 3f2e18b07c24686bd7d67839daac3566d634243d (patch) | |
tree | 3334c93f99971488fa7982d1227ee8c4b569b277 /gmodule | |
parent | 0f5d2748719627fafbdcfd67a776002cd6ffae81 (diff) | |
download | glib-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.c | 6 |
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); |