diff --git a/lib/lwres/getaddrinfo.c b/lib/lwres/getaddrinfo.c index 682a307f70..7eeb20cc76 100644 --- a/lib/lwres/getaddrinfo.c +++ b/lib/lwres/getaddrinfo.c @@ -3,7 +3,7 @@ * The Berkeley Software Design Inc. software License Agreement specifies * the terms and conditions for redistribution. * - * BSDI $Id: getaddrinfo.c,v 1.19 2000/06/15 18:28:09 explorer Exp $ + * BSDI $Id: getaddrinfo.c,v 1.20 2000/06/15 18:49:53 explorer Exp $ */ #include @@ -227,6 +227,12 @@ lwres_getaddrinfo(const char *hostname, const char *servname, ntmp[sizeof(ntmp) - 1] = '\0'; p = strchr(ntmp, '%'); ep = NULL; + + /* + * vendors may want to support non-numeric + * scopeid around here. + */ + if (p != NULL) scopeid = (lwres_uint32_t)strtoul(p + 1, &ep, 10); @@ -277,11 +283,12 @@ lwres_getaddrinfo(const char *hostname, const char *servname, SIN(ai->ai_addr)->sin_port = port; memcpy((char *)ai->ai_addr + addroff, abuf, addrsize); if (flags & AI_CANONNAME) { - if (ai->ai_family == AF_INET6) - SIN6(ai->ai_addr)->sin6_scope_id = scopeid; + if (ai->ai_family == AF_INET6) + SIN6(ai->ai_addr)->sin6_scope_id = scopeid; if (lwres_getnameinfo(ai->ai_addr, - ai->ai_addrlen, nbuf, sizeof(nbuf), NULL, 0, - NI_NUMERICHOST) == 0) { + ai->ai_addrlen, nbuf, sizeof(nbuf), + NULL, 0, + NI_NUMERICHOST) == 0) { ai->ai_canonname = strdup(nbuf); } else { /* XXX raise error? */ diff --git a/lib/lwres/getnameinfo.c b/lib/lwres/getnameinfo.c index 8513832270..bf6474b3a9 100644 --- a/lib/lwres/getnameinfo.c +++ b/lib/lwres/getnameinfo.c @@ -195,7 +195,7 @@ lwres_getnameinfo(const struct sockaddr *sa, size_t salen, char *host, char *p = numaddr + strlen(numaddr); const char *stringscope = NULL; #if 0 - if (flags & NI_NUMERICSCOPE) { + if ((flags & NI_NUMERICSCOPE) == 0) { /* * vendors may want to add support for * non-numeric scope identifier. @@ -203,7 +203,7 @@ lwres_getnameinfo(const struct sockaddr *sa, size_t salen, char *host, stringscope = foo; } #endif - if (!stringscope) { + if (stringscope == NULL) { snprintf(p, sizeof(numaddr) - (p - numaddr), "%%%u", ((const struct sockaddr_in6 *)sa)->sin6_scope_id);