summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlberts Muktupāvels <alberts.muktupavels@gmail.com>2020-10-21 13:59:45 +0300
committerAlberts Muktupāvels <alberts.muktupavels@gmail.com>2020-10-21 13:59:45 +0300
commitb960be4fcbd0034fa9bc7bf1b9d081201c27cca3 (patch)
tree12e37b92b1c9c272ee54618654bbd154b2747209 /src
parent40fca63905e3daa3a20ec1d3bd4ccb22e5f24623 (diff)
downloadmetacity-b960be4fcbd0034fa9bc7bf1b9d081201c27cca3.tar.gz
session: check fcntl return value
This function can fail. CID 1220275.
Diffstat (limited to 'src')
-rw-r--r--src/core/session.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/core/session.c b/src/core/session.c
index 3252f0e6..6d7ea57b 100644
--- a/src/core/session.c
+++ b/src/core/session.c
@@ -131,12 +131,17 @@ new_ice_connection (IceConn connection, IcePointer client_data, Bool opening,
/* Make sure we don't pass on these file descriptors to any
* exec'ed children
*/
+ int fd;
+ int flags;
GIOChannel *channel;
- fcntl (IceConnectionNumber (connection), F_SETFD,
- fcntl (IceConnectionNumber (connection), F_GETFD, 0) | FD_CLOEXEC);
+ fd = IceConnectionNumber (connection);
+ flags = fcntl (fd, F_GETFD);
- channel = g_io_channel_unix_new (IceConnectionNumber (connection));
+ if (flags == -1 || fcntl (fd, F_SETFD, flags | FD_CLOEXEC) == -1)
+ g_warning ("Failed to set FD_CLOEXEC flag: %s", strerror (errno));
+
+ channel = g_io_channel_unix_new (fd);
input_id = g_io_add_watch (channel,
G_IO_IN | G_IO_ERR,