From 8f3a251b076d7438bac8e23db9b50a639425ddab Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 23 Oct 2014 16:10:44 +0200 Subject: [PATCH] bind host. Always append :0 or force :0 YAZ-795 This is to ensure that tcpip_getaddrinfo for bind host do not accidently use : from IPV6 address. --- src/tcpip.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/tcpip.c b/src/tcpip.c index a14f66e..47655a9 100644 --- a/src/tcpip.c +++ b/src/tcpip.c @@ -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) { -- 1.7.10.4