summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Koegel <eric.koegel@gmail.com>2014-09-23 19:45:48 +0300
committerEric Koegel <eric.koegel@gmail.com>2014-09-23 19:47:41 +0300
commit77d39eb0314247e5e129ab53ae1da5d699be52ca (patch)
tree4eebfa2faada33e0b2b65577d4c24f506dc5decc
parent0afe3ba5ef6539cf79d773fe33027d63b672b657 (diff)
downloadxfce4-session-77d39eb0314247e5e129ab53ae1da5d699be52ca.tar.gz
Add error checking for fcntl
Coverity warns about system calls that lack error checking. At a minimum this may help point out other problems if these warnings show up.
-rw-r--r--xfce4-session/ice-layer.c14
-rw-r--r--xfce4-session/xfsm-compat-gnome.c9
2 files changed, 20 insertions, 3 deletions
diff --git a/xfce4-session/ice-layer.c b/xfce4-session/ice-layer.c
index 4ad0bc52..9ae74738 100644
--- a/xfce4-session/ice-layer.c
+++ b/xfce4-session/ice-layer.c
@@ -134,6 +134,7 @@ ice_connection_watch (IceConn ice_conn,
GIOChannel *channel;
guint watchid;
gint fd;
+ gint ret;
if (opening)
{
@@ -146,7 +147,11 @@ ice_connection_watch (IceConn ice_conn,
/* Make sure we don't pass on these file descriptors to an
* exec'd child process.
*/
- fcntl (fd, F_SETFD, fcntl (fd, F_GETFD, 0) | FD_CLOEXEC);
+ ret = fcntl (fd, F_SETFD, fcntl (fd, F_GETFD, 0) | FD_CLOEXEC);
+ if (ret == -1)
+ {
+ perror ("ice_connection_watch: fcntl (fd, F_SETFD, fcntl (fd, F_GETFD, 0) | FD_CLOEXEC) failed");
+ }
channel = g_io_channel_unix_new (fd);
watchid = g_io_add_watch_full (channel, G_PRIORITY_DEFAULT,
@@ -297,6 +302,7 @@ ice_setup_listeners (int num_listeners,
FILE *setup_fp;
int fd;
int n;
+ int ret;
IceSetIOErrorHandler (ice_error_handler);
IceAddConnectionWatch (ice_connection_watch, manager);
@@ -321,7 +327,11 @@ ice_setup_listeners (int num_listeners,
/* Make sure we don't pass on these file descriptors to an
* exec'd child process.
*/
- fcntl (fd, F_SETFD, fcntl (fd, F_GETFD, 0) | FD_CLOEXEC);
+ ret = fcntl (fd, F_SETFD, fcntl (fd, F_GETFD, 0) | FD_CLOEXEC);
+ if (ret == -1)
+ {
+ perror ("ice_setup_listeners: fcntl (fd, F_SETFD, fcntl (fd, F_GETFD, 0) | FD_CLOEXEC) failed");
+ }
channel = g_io_channel_unix_new (fd);
g_io_add_watch (channel, G_IO_ERR | G_IO_HUP | G_IO_IN,
diff --git a/xfce4-session/xfsm-compat-gnome.c b/xfce4-session/xfsm-compat-gnome.c
index d02df5ac..05bd9622 100644
--- a/xfce4-session/xfsm-compat-gnome.c
+++ b/xfce4-session/xfsm-compat-gnome.c
@@ -75,12 +75,19 @@ child_setup (gpointer user_data)
gint open_max;
gint fd;
char *fd_str;
+ int ret;
open_max = sysconf (_SC_OPEN_MAX);
for (fd = 3; fd < open_max; fd++)
{
if (fd != keyring_lifetime_pipe[0])
- fcntl (fd, F_SETFD, FD_CLOEXEC);
+ {
+ ret = fcntl (fd, F_SETFD, FD_CLOEXEC);
+ if (ret == -1)
+ {
+ perror ("child_setup: fcntl (fd, F_SETFD, FD_CLOEXEC) failed");
+ }
+ }
}
fd_str = g_strdup_printf ("%d", keyring_lifetime_pipe[0]);