multipathd: fix some small bugs for cli socket
authortang.junhui <tang.junhui@zte.com.cn>
Thu, 11 Aug 2016 11:01:20 +0000 (19:01 +0800)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Tue, 16 Aug 2016 07:06:58 +0000 (09:06 +0200)
1) mpath_recv_reply_len() should return error when the length which received by read_all() is wrong;
2) The buffer which *reply point to maybe null when mpath_recv_reply() return with success,
   so the caller needs to determine whether it is null, and then to use
   it.

Signed-off-by: tang.junhui <tang.junhui@zte.com.cn>
libmpathcmd/mpath_cmd.c
multipathd/uxclnt.c
multipathd/uxlsnr.c

index 2290ecb..c058479 100644 (file)
@@ -112,7 +112,7 @@ ssize_t mpath_recv_reply_len(int fd, unsigned int timeout)
                return ret;
        if (ret != sizeof(len)) {
                errno = EIO;
-               return ret;
+               return -1;
        }
        return len;
 }
index 62ff6f4..c5c32ea 100644 (file)
@@ -28,6 +28,9 @@
 
 static void print_reply(char *s)
 {
+       if (!s)
+               return;
+
        if (isatty(1)) {
                printf("%s", s);
                return;
index fa29b2a..7a9faf3 100644 (file)
@@ -243,6 +243,10 @@ void * uxsock_listen(uxsock_trigger_fn uxsock_trigger, void * trigger_data)
                                        dead_client(c);
                                        continue;
                                }
+                               if (!inbuf) {
+                                       condlog(4, "recv_packet get null request");
+                                       continue;
+                               }
                                condlog(4, "cli[%d]: Got request [%s]",
                                        i, inbuf);
                                uxsock_trigger(inbuf, &reply, &rlen,