Module: xenomai-2.6
Branch: master
Commit: d362574ca09111e1405754194f635b13caa2fc31
URL:    
http://git.xenomai.org/?p=xenomai-2.6.git;a=commit;h=d362574ca09111e1405754194f635b13caa2fc31

Author: Philippe Gerum <r...@xenomai.org>
Date:   Wed Aug 13 11:06:24 2014 +0200

rtipc: fix address reset in connect()

---

 ksrc/drivers/ipc/bufp.c |    8 +++++---
 ksrc/drivers/ipc/iddp.c |    8 +++++---
 ksrc/drivers/ipc/xddp.c |    8 +++++---
 3 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/ksrc/drivers/ipc/bufp.c b/ksrc/drivers/ipc/bufp.c
index 9fb52ee..6f20cfc 100644
--- a/ksrc/drivers/ipc/bufp.c
+++ b/ksrc/drivers/ipc/bufp.c
@@ -760,12 +760,14 @@ fail:
 static int __bufp_connect_socket(struct bufp_socket *sk,
                                 struct sockaddr_ipc *sa)
 {
+       struct sockaddr_ipc _sa;
        struct bufp_socket *rsk;
        xnhandle_t h;
        int ret;
 
        if (sa == NULL) {
-               sa = &nullsa;
+               _sa = nullsa;
+               sa = &_sa;
                goto set_assoc;
        }
 
@@ -808,8 +810,8 @@ static int __bufp_connect_socket(struct bufp_socket *sk,
                );
                if (ret)
                        return ret;
-       }
-
+       } else if (sa->sipc_port < 0)
+               sa = &nullsa;
 set_assoc:
        RTDM_EXECUTE_ATOMICALLY(
                if (!test_bit(_BUFP_BOUND, &sk->status))
diff --git a/ksrc/drivers/ipc/iddp.c b/ksrc/drivers/ipc/iddp.c
index b9bdbd2..51a9074 100644
--- a/ksrc/drivers/ipc/iddp.c
+++ b/ksrc/drivers/ipc/iddp.c
@@ -623,12 +623,14 @@ fail:
 static int __iddp_connect_socket(struct iddp_socket *sk,
                                 struct sockaddr_ipc *sa)
 {
+       struct sockaddr_ipc _sa;
        struct iddp_socket *rsk;
        xnhandle_t h;
        int ret;
 
        if (sa == NULL) {
-               sa = &nullsa;
+               _sa = nullsa;
+               sa = &_sa;
                goto set_assoc;
        }
 
@@ -671,8 +673,8 @@ static int __iddp_connect_socket(struct iddp_socket *sk,
                );
                if (ret)
                        return ret;
-       }
-
+       } else if (sa->sipc_port < 0)
+               sa = &nullsa;
 set_assoc:
        RTDM_EXECUTE_ATOMICALLY(
                if (!test_bit(_IDDP_BOUND, &sk->status))
diff --git a/ksrc/drivers/ipc/xddp.c b/ksrc/drivers/ipc/xddp.c
index 1c69e9c..c38ac56 100644
--- a/ksrc/drivers/ipc/xddp.c
+++ b/ksrc/drivers/ipc/xddp.c
@@ -773,12 +773,14 @@ static int __xddp_bind_socket(struct rtipc_private *priv,
 static int __xddp_connect_socket(struct xddp_socket *sk,
                                 struct sockaddr_ipc *sa)
 {
+       struct sockaddr_ipc _sa;
        struct xddp_socket *rsk;
        xnhandle_t h;
        int ret;
 
        if (sa == NULL) {
-               sa = &nullsa;
+               _sa = nullsa;
+               sa = &_sa;
                goto set_assoc;
        }
 
@@ -821,8 +823,8 @@ static int __xddp_connect_socket(struct xddp_socket *sk,
                );
                if (ret)
                        return ret;
-       }
-
+       } else if (sa->sipc_port < 0)
+               sa = &nullsa;
 set_assoc:
        RTDM_EXECUTE_ATOMICALLY(
                if (!test_bit(_XDDP_BOUND, &sk->status))


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to