diff options
-rw-r--r-- | src/include/ChangeLog | 6 | ||||
-rw-r--r-- | src/include/fake-addrinfo.h | 24 |
2 files changed, 19 insertions, 11 deletions
diff --git a/src/include/ChangeLog b/src/include/ChangeLog index 954fd43440..fea9e3ee1f 100644 --- a/src/include/ChangeLog +++ b/src/include/ChangeLog @@ -1,3 +1,9 @@ +2003-04-07 Ken Raeburn <raeburn@mit.edu> + + * fake-addrinfo.h (getaddrinfo) [NUMERIC_SERVICE_BROKEN]: + Overwrite the port number only if a numeric service port was + supplied. + 2003-04-01 Ken Raeburn <raeburn@mit.edu> * fake-addrinfo.h (COPY_FIRST_CANONNAME) [_AIX]: Define. diff --git a/src/include/fake-addrinfo.h b/src/include/fake-addrinfo.h index 7474543fcd..b019c38234 100644 --- a/src/include/fake-addrinfo.h +++ b/src/include/fake-addrinfo.h @@ -1055,17 +1055,19 @@ getaddrinfo (const char *name, const char *serv, const struct addrinfo *hint, #endif #ifdef NUMERIC_SERVICE_BROKEN - for (ai = *result; ai; ai = ai->ai_next) { - if (socket_type != 0 && ai->ai_socktype == 0) - /* Is this check actually needed? */ - ai->ai_socktype = socket_type; - switch (ai->ai_family) { - case AF_INET: - ((struct sockaddr_in *)ai->ai_addr)->sin_port = service_port; - break; - case AF_INET6: - ((struct sockaddr_in6 *)ai->ai_addr)->sin6_port = service_port; - break; + if (service_port != 0) { + for (ai = *result; ai; ai = ai->ai_next) { + if (socket_type != 0 && ai->ai_socktype == 0) + /* Is this check actually needed? */ + ai->ai_socktype = socket_type; + switch (ai->ai_family) { + case AF_INET: + ((struct sockaddr_in *)ai->ai_addr)->sin_port = service_port; + break; + case AF_INET6: + ((struct sockaddr_in6 *)ai->ai_addr)->sin6_port = service_port; + break; + } } } #endif |