bind host. Always append :0 or force :0 YAZ-795
[yaz-moved-to-github.git] / src / tcpip.c
index a14f66e..47655a9 100644 (file)
@@ -261,7 +261,15 @@ COMSTACK yaz_tcpip_create2(int s, int flags, int protocol,
     if (bind_host)
     {
         tcpip_state *sp = (tcpip_state *) p->cprivate;
-        sp->bind_host = xstrdup(bind_host);
+        char *cp;
+        sp->bind_host = xmalloc(strlen(bind_host) + 4);
+        strcpy(sp->bind_host, bind_host);
+        cp = strrchr(sp->bind_host, ':');
+
+        if (!cp || cp[1] == '\0')
+            strcat(sp->bind_host, ":0");
+        else
+            strcpy(cp, ":0");
     }
     if (connect_host)
     {