[Xfce4-commits] [xfce/xfce4-session] 01/01: Add error checking for fcntl

noreply at xfce.org noreply at xfce.org
Tue Sep 23 18:51:26 CEST 2014


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch master
in repository xfce/xfce4-session.

commit 77d39eb0314247e5e129ab53ae1da5d699be52ca
Author: Eric Koegel <eric.koegel at gmail.com>
Date:   Tue Sep 23 19:45:48 2014 +0300

    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.
---
 xfce4-session/ice-layer.c         |   14 ++++++++++++--
 xfce4-session/xfsm-compat-gnome.c |    9 ++++++++-
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/xfce4-session/ice-layer.c b/xfce4-session/ice-layer.c
index 4ad0bc5..9ae7473 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 d02df5a..05bd962 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]);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list