For abstract sockets, the addrlen parameter should be the actual
length of socket's name.  Otherwise socket gets padded with some
number of NULs.
---
 usr/iscsid_req.c | 3 ++-
 usr/mgmt_ipc.c   | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/usr/iscsid_req.c b/usr/iscsid_req.c
index 0902011..94896b3 100644
--- a/usr/iscsid_req.c
+++ b/usr/iscsid_req.c
@@ -73,7 +73,8 @@ static int iscsid_connect(int *fd, int start_iscsid)
         * Trying to connect with exponential backoff
         */
        for (nsec = 1; nsec <= MAXSLEEP; nsec <<= 1) {
-               if (connect(*fd, (struct sockaddr *) &addr, sizeof(addr)) == 0)
+               if (connect(*fd, (struct sockaddr *) &addr, 
+                       offsetof(struct sockaddr_un, sun_path) + 
strlen(ISCSIADM_NAMESPACE) + 1) == 0)
                        /* Connection established */
                        return ISCSI_SUCCESS;
 
diff --git a/usr/mgmt_ipc.c b/usr/mgmt_ipc.c
index 5c39c2e..36f5d02 100644
--- a/usr/mgmt_ipc.c
+++ b/usr/mgmt_ipc.c
@@ -57,7 +57,8 @@ mgmt_ipc_listen(void)
        memcpy((char *) &addr.sun_path + 1, ISCSIADM_NAMESPACE,
                strlen(ISCSIADM_NAMESPACE));
 
-       if ((err = bind(fd, (struct sockaddr *) &addr, sizeof(addr))) < 0) {
+       if ((err = bind(fd, (struct sockaddr *) &addr, 
+               offsetof(struct sockaddr_un, sun_path) + 
strlen(ISCSIADM_NAMESPACE) + 1)) < 0) {
                log_error("Can not bind IPC socket");
                close(fd);
                return err;
-- 
1.7.11.7

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To post to this group, send email to open-iscsi@googlegroups.com.
To unsubscribe from this group, send email to 
open-iscsi+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/open-iscsi?hl=en.

Reply via email to