multipath-tools: Fix uevent handling code
authorBenjamin Marzinski <bmarzins@redhat.com>
Mon, 3 Aug 2009 21:59:05 +0000 (16:59 -0500)
committerChristophe Varoqui <christophe.varoqui@free.fr>
Tue, 4 Aug 2009 21:34:07 +0000 (23:34 +0200)
Multipathd wasn't setting buflen when it read in a uevent message.  This was
causing buflen to be used unitialized, and would often keep multipathd from
processing uevents.  This patch correctly initializes buflen to the size of the
buffer received.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
libmultipath/uevent.c

index 0ed7e12d56e798aee082e532052b0392286b8d8e..50ed9c92dfc1313f0c73c197346dd7abf86aedd3 100644 (file)
@@ -231,7 +231,8 @@ int uevent_listen(int (*uev_trigger)(struct uevent *, void * trigger_data),
                smsg.msg_control = cred_msg;
                smsg.msg_controllen = sizeof(cred_msg);
 
-               if (recvmsg(sock, &smsg, 0) < 0) {
+               buflen = recvmsg(sock, &smsg, 0);
+               if (buflen < 0) {
                        if (errno != EINTR)
                                condlog(0, "error receiving message");
                        continue;
@@ -286,8 +287,10 @@ int uevent_listen(int (*uev_trigger)(struct uevent *, void * trigger_data),
                /* action string */
                uev->action = buffer;
                pos = strchr(buffer, '@');
-               if (!pos)
+               if (!pos) {
+                       condlog(3, "bad action string '%s'", buffer);
                        continue;
+               }
                pos[0] = '\0';
 
                /* sysfs path */