Use "e" mode flag in fopen () calls for race-free setting of the close-on-exec flag

All Unix CRTs examined: glibc, musl, BSDs, Apple libc, Android bionic
ignore unknown fopen () mode flags, so this flag can be added
unconditionally for Unix builds.

Only Windows CRT is intolerant of these, so the single case in
g_dbus_address_connect () where the fopen () call is shared between Unix
and Windows needs appropriate platform-specific handling.

Skipped the call sites in libcharset and xdgmime copylibs.
This commit is contained in:
Maciej S. Szmigiero
2023-02-19 16:46:03 +01:00
committed by Philip Withnall
parent 3f2e18b07c
commit 0e7bf99ec2
3 changed files with 9 additions and 3 deletions

View File

@@ -3166,7 +3166,7 @@ _resolve_dev_root (void)
/* see if device with similar major:minor as /dev/root is mention
* in /etc/mtab (it usually is)
*/
f = fopen ("/etc/mtab", "r");
f = fopen ("/etc/mtab", "re");
if (f != NULL)
{
struct mntent *entp;