--- ../tcplib/tcplib.c.orig Fri Dec 17 02:27:36 1999 +++ ../tcplib/tcplib.c Sun Jan 16 07:37:37 2000 @@ -12,7 +12,7 @@ * Last Edit : 1999-12/17 * Author : MSRS3 Âð´Ö ðý * - * IPv6 support: 1999-11/19,22,30 by H.YOSHIFUJI + * IPv6 support: 1999-11/19,22,30, 12/04,16,24 by H.YOSHIFUJI */ #include "compat.h" @@ -229,6 +229,7 @@ memset(&hints, 0, sizeof(hints)); hints.ai_family = PF_UNSPEC; hints.ai_socktype = SOCK_STREAM; + res = res0 = NULL; gaierr = getaddrinfo(server_name, serv_buff, &hints, &res0); if (gaierr) { if ((gaierr == EAI_SERVICE) && @@ -829,8 +830,7 @@ *port++ = '\0'; } #ifdef INET6 - strncpy(hostport, host, sizeof(hostport)); - hostport[sizeof(hostport) - 1] = '\0'; + strcpy(hostport, host); /* ok: strlen(hostport)+1 >= strlen(host)+1 */ #endif /* INET6 */ return(port); } @@ -862,7 +862,7 @@ hints.ai_family = PF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_CANONNAME; - + res0 = NULL; if (getaddrinfo(host, NULL, &hints, &res0) == 0) { s = res0->ai_canonname; } @@ -876,12 +876,16 @@ if (canonname != (char*)NULL) { t = strncpy(canonname, s, length); } else { +#ifdef DONT_HAVE_STRDUP + if (t = (s != (char *)NULL) ? ((char *)malloc(strlen(s)+1)) : (char *)NULL) strcpy(t,s); +#else t = strdup(s); +#endif } + } #ifdef INET6 - freeaddrinfo(res0); + if(res0) freeaddrinfo(res0); #endif /* INET6 */ - } return(t); }