From 6df3aae973b9d7b1063dec9f5c0e76735ec30455 Mon Sep 17 00:00:00 2001 From: Packit Bot Date: May 04 2021 22:21:35 +0000 Subject: Apply patch 0003-glocalfileoutputstream-Add-a-missing-O_CLOEXEC-flag-.patch patch_name: 0003-glocalfileoutputstream-Add-a-missing-O_CLOEXEC-flag-.patch present_in_specfile: true location_in_specfile: 31 --- diff --git a/gio/glocalfileoutputstream.c b/gio/glocalfileoutputstream.c index 4a7766f..275770f 100644 --- a/gio/glocalfileoutputstream.c +++ b/gio/glocalfileoutputstream.c @@ -56,6 +56,12 @@ #define O_BINARY 0 #endif +#ifndef O_CLOEXEC +#define O_CLOEXEC 0 +#else +#define HAVE_O_CLOEXEC 1 +#endif + struct _GLocalFileOutputStreamPrivate { char *tmp_filename; char *original_filename; @@ -1127,7 +1133,7 @@ _g_local_file_output_stream_replace (const char *filename, sync_on_close = FALSE; /* If the file doesn't exist, create it */ - open_flags = O_CREAT | O_EXCL | O_BINARY; + open_flags = O_CREAT | O_EXCL | O_BINARY | O_CLOEXEC; if (readable) open_flags |= O_RDWR; else @@ -1157,8 +1163,11 @@ _g_local_file_output_stream_replace (const char *filename, set_error_from_open_errno (filename, error); return NULL; } - - +#if !defined(HAVE_O_CLOEXEC) && defined(F_SETFD) + else + fcntl (fd, F_SETFD, FD_CLOEXEC); +#endif + stream = g_object_new (G_TYPE_LOCAL_FILE_OUTPUT_STREAM, NULL); stream->priv->fd = fd; stream->priv->sync_on_close = sync_on_close;