ctdb-daemon: Fix CID 1362726 Unchecked return value from library
authorMartin Schwenke <martin@meltin.net>
Wed, 10 Aug 2016 07:16:34 +0000 (17:16 +1000)
committerMartin Schwenke <martins@samba.org>
Wed, 17 Aug 2016 21:00:25 +0000 (23:00 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ctdb_daemon.c

index 267d8994dd614d3f3aadc2b1d791198a42f0fac2..6c8129c856d7c1749eb2a252c60e5fbf9bfefb6f 100644 (file)
@@ -984,6 +984,7 @@ static void ctdb_accept_client(struct tevent_context *ev,
 static int ux_socket_bind(struct ctdb_context *ctdb)
 {
        struct sockaddr_un addr;
+       int ret;
 
        ctdb->daemon.sd = socket(AF_UNIX, SOCK_STREAM, 0);
        if (ctdb->daemon.sd == -1) {
@@ -1007,7 +1008,15 @@ static int ux_socket_bind(struct ctdb_context *ctdb)
        unlink(ctdb->daemon.name);
 
        set_close_on_exec(ctdb->daemon.sd);
-       set_blocking(ctdb->daemon.sd, false);
+
+       ret = set_blocking(ctdb->daemon.sd, false);
+       if (ret != 0) {
+               DEBUG(DEBUG_ERR,
+                     (__location__
+                      " failed to set socket non-blocking (%s)\n",
+                      strerror(errno)));
+               goto failed;
+       }
 
        if (bind(ctdb->daemon.sd, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
                DEBUG(DEBUG_CRIT,("Unable to bind on ctdb socket '%s'\n", ctdb->daemon.name));