[metacity] session: check fcntl return value
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity] session: check fcntl return value
- Date: Wed, 21 Oct 2020 11:07:01 +0000 (UTC)
commit b960be4fcbd0034fa9bc7bf1b9d081201c27cca3
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Wed Oct 21 13:59:45 2020 +0300
session: check fcntl return value
This function can fail.
CID 1220275.
src/core/session.c | 11 ++++++++---
1 file 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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]