Skip to contentSkip to conversation

multipathd: fix some small bugs for cli socket

PATCH New [email protected] 1 participant 1 message Aug 11, 2016 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 multipathd: fix some small bugs for cli socket

From: "tang.junhui" <[email protected]>

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.

---
 libmpathcmd/mpath_cmd.c | 2 +-
 multipathd/uxclnt.c     | 3 +++
 multipathd/uxlsnr.c     | 4 ++++
 3 files changed, 8 insertions(+), 1 deletion(-)
libmpathcmd/mpath_cmd.c +1 -1
index 2290ecb..c058479 100644
@@ -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;
 }
multipathd/uxclnt.c +3 -0
index 62ff6f4..c5c32ea 100644
@@ -28,6 +28,9 @@
 
 static void print_reply(char *s)
 {
+	if (!s)
+		return;
+
 	if (isatty(1)) {
 		printf("%s", s);
 		return;
multipathd/uxlsnr.c +4 -0
index fa29b2a..7a9faf3 100644
@@ -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,
Signature · 1 line
2.8.1.windows.1