diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | openbsd-compat/fake-getaddrinfo.c | 24 | ||||
-rw-r--r-- | openbsd-compat/fake-getaddrinfo.h | 4 |
3 files changed, 24 insertions, 10 deletions
@@ -1,3 +1,7 @@ +20030206 + - (djm) Teach fake-getaddrinfo to use getservbyname() when provided a + string service name. Suggested by markus@, review by itojun@ + 20030131 - (bal) AIX 4.2.1 lacks nanosleep(). Patch to use nsleep() provided by dtucker@zip.com.au @@ -1090,4 +1094,4 @@ save auth method before monitor_reset_key_state(); bugzilla bug #284; ok provos@ -$Id: ChangeLog,v 1.2591 2003/02/01 04:43:34 mouring Exp $ +$Id: ChangeLog,v 1.2592 2003/02/05 23:51:06 djm Exp $ diff --git a/openbsd-compat/fake-getaddrinfo.c b/openbsd-compat/fake-getaddrinfo.c index 67e9eb78..2a2f269c 100644 --- a/openbsd-compat/fake-getaddrinfo.c +++ b/openbsd-compat/fake-getaddrinfo.c @@ -12,10 +12,10 @@ #include "includes.h" #include "ssh.h" -RCSID("$Id: fake-getaddrinfo.c,v 1.2 2001/02/09 01:55:36 djm Exp $"); +RCSID("$Id: fake-getaddrinfo.c,v 1.3 2003/02/05 23:50:42 djm Exp $"); #ifndef HAVE_GAI_STRERROR -char *gai_strerror(int ecode) +const char *gai_strerror(int ecode) { switch (ecode) { case EAI_NODATA: @@ -67,13 +67,23 @@ int getaddrinfo(const char *hostname, const char *servname, { struct addrinfo *cur, *prev = NULL; struct hostent *hp; + struct servent *sp; struct in_addr in; - int i, port; + int i; + long int port; - if (servname) - port = htons(atoi(servname)); - else - port = 0; + port = 0; + if (servname != NULL) { + char *cp; + + port = strtol(servname, &cp, 10); + if (port > 0 && port <= 65535 && *cp == '\0') + port = htons(port); + else if ((sp = getservbyname(servname, NULL)) != NULL) + port = sp->s_port; + else + port = 0; + } if (hints && hints->ai_flags & AI_PASSIVE) { if (NULL != (*res = malloc_ai(port, htonl(0x00000000)))) diff --git a/openbsd-compat/fake-getaddrinfo.h b/openbsd-compat/fake-getaddrinfo.h index afd0226e..a14a2cc1 100644 --- a/openbsd-compat/fake-getaddrinfo.h +++ b/openbsd-compat/fake-getaddrinfo.h @@ -1,4 +1,4 @@ -/* $Id: fake-getaddrinfo.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */ +/* $Id: fake-getaddrinfo.h,v 1.3 2003/02/05 23:50:43 djm Exp $ */ #ifndef _FAKE_GETADDRINFO_H #define _FAKE_GETADDRINFO_H @@ -37,7 +37,7 @@ int getaddrinfo(const char *hostname, const char *servname, #endif /* !HAVE_GETADDRINFO */ #ifndef HAVE_GAI_STRERROR -char *gai_strerror(int ecode); +const char *gai_strerror(int ecode); #endif /* !HAVE_GAI_STRERROR */ #ifndef HAVE_FREEADDRINFO |