Review at  https://gerrit.osmocom.org/3333

osmo_sock_init2(): Fix creation of non-bound sockets

If osmo_sock_init2() was used with CONNECT flag but without BIND
flag, an invalid check for "did we create a socket yet" caused
the socket to never be created, and subsequently the entire function
to return an error.

Change-Id: I0206dbb9c5b8f74d7fb088576941b092acd2ca22
---
M src/socket.c
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/33/3333/1

diff --git a/src/socket.c b/src/socket.c
index ca50b6f..457c991 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -239,7 +239,7 @@
                                rp->ai_protocol = proto;
                        }
 
-                       if (!sfd) {
+                       if (sfd < 0) {
                                sfd = socket_helper(rp, flags);
                                if (sfd < 0)
                                        continue;

-- 
To view, visit https://gerrit.osmocom.org/3333
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0206dbb9c5b8f74d7fb088576941b092acd2ca22
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <[email protected]>

Reply via email to