[dm-devel] [PATCH] multipathd: fix some small bugs for cli socket
tang.junhui at zte.com.cn
tang.junhui at zte.com.cn
Thu Aug 11 11:01:20 UTC 2016
From: "tang.junhui" <tang.junhui at zte.com.cn>
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 at zte.com.cn>
---
libmpathcmd/mpath_cmd.c | 2 +-
multipathd/uxclnt.c | 3 +++
multipathd/uxlsnr.c | 4 ++++
3 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/libmpathcmd/mpath_cmd.c b/libmpathcmd/mpath_cmd.c
index 2290ecb..c058479 100644
--- a/libmpathcmd/mpath_cmd.c
+++ b/libmpathcmd/mpath_cmd.c
@@ -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;
}
diff --git a/multipathd/uxclnt.c b/multipathd/uxclnt.c
index 62ff6f4..c5c32ea 100644
--- a/multipathd/uxclnt.c
+++ b/multipathd/uxclnt.c
@@ -28,6 +28,9 @@
static void print_reply(char *s)
{
+ if (!s)
+ return;
+
if (isatty(1)) {
printf("%s", s);
return;
diff --git a/multipathd/uxlsnr.c b/multipathd/uxlsnr.c
index fa29b2a..7a9faf3 100644
--- a/multipathd/uxlsnr.c
+++ b/multipathd/uxlsnr.c
@@ -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,
--
2.8.1.windows.1
More information about the dm-devel
mailing list