summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--openbsd-compat/fake-getaddrinfo.c24
-rw-r--r--openbsd-compat/fake-getaddrinfo.h4
3 files changed, 24 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index a6acb5c50..af9bf9a48 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
120030206
2 - (djm) Teach fake-getaddrinfo to use getservbyname() when provided a
3 string service name. Suggested by markus@, review by itojun@
4
120030131 520030131
2 - (bal) AIX 4.2.1 lacks nanosleep(). Patch to use nsleep() provided by 6 - (bal) AIX 4.2.1 lacks nanosleep(). Patch to use nsleep() provided by
3 dtucker@zip.com.au 7 dtucker@zip.com.au
@@ -1090,4 +1094,4 @@
1090 save auth method before monitor_reset_key_state(); bugzilla bug #284; 1094 save auth method before monitor_reset_key_state(); bugzilla bug #284;
1091 ok provos@ 1095 ok provos@
1092 1096
1093$Id: ChangeLog,v 1.2591 2003/02/01 04:43:34 mouring Exp $ 1097$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 67e9eb788..2a2f269cb 100644
--- a/openbsd-compat/fake-getaddrinfo.c
+++ b/openbsd-compat/fake-getaddrinfo.c
@@ -12,10 +12,10 @@
12#include "includes.h" 12#include "includes.h"
13#include "ssh.h" 13#include "ssh.h"
14 14
15RCSID("$Id: fake-getaddrinfo.c,v 1.2 2001/02/09 01:55:36 djm Exp $"); 15RCSID("$Id: fake-getaddrinfo.c,v 1.3 2003/02/05 23:50:42 djm Exp $");
16 16
17#ifndef HAVE_GAI_STRERROR 17#ifndef HAVE_GAI_STRERROR
18char *gai_strerror(int ecode) 18const char *gai_strerror(int ecode)
19{ 19{
20 switch (ecode) { 20 switch (ecode) {
21 case EAI_NODATA: 21 case EAI_NODATA:
@@ -67,13 +67,23 @@ int getaddrinfo(const char *hostname, const char *servname,
67{ 67{
68 struct addrinfo *cur, *prev = NULL; 68 struct addrinfo *cur, *prev = NULL;
69 struct hostent *hp; 69 struct hostent *hp;
70 struct servent *sp;
70 struct in_addr in; 71 struct in_addr in;
71 int i, port; 72 int i;
73 long int port;
72 74
73 if (servname) 75 port = 0;
74 port = htons(atoi(servname)); 76 if (servname != NULL) {
75 else 77 char *cp;
76 port = 0; 78
79 port = strtol(servname, &cp, 10);
80 if (port > 0 && port <= 65535 && *cp == '\0')
81 port = htons(port);
82 else if ((sp = getservbyname(servname, NULL)) != NULL)
83 port = sp->s_port;
84 else
85 port = 0;
86 }
77 87
78 if (hints && hints->ai_flags & AI_PASSIVE) { 88 if (hints && hints->ai_flags & AI_PASSIVE) {
79 if (NULL != (*res = malloc_ai(port, htonl(0x00000000)))) 89 if (NULL != (*res = malloc_ai(port, htonl(0x00000000))))
diff --git a/openbsd-compat/fake-getaddrinfo.h b/openbsd-compat/fake-getaddrinfo.h
index afd0226e2..a14a2cc11 100644
--- a/openbsd-compat/fake-getaddrinfo.h
+++ b/openbsd-compat/fake-getaddrinfo.h
@@ -1,4 +1,4 @@
1/* $Id: fake-getaddrinfo.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */ 1/* $Id: fake-getaddrinfo.h,v 1.3 2003/02/05 23:50:43 djm Exp $ */
2 2
3#ifndef _FAKE_GETADDRINFO_H 3#ifndef _FAKE_GETADDRINFO_H
4#define _FAKE_GETADDRINFO_H 4#define _FAKE_GETADDRINFO_H
@@ -37,7 +37,7 @@ int getaddrinfo(const char *hostname, const char *servname,
37#endif /* !HAVE_GETADDRINFO */ 37#endif /* !HAVE_GETADDRINFO */
38 38
39#ifndef HAVE_GAI_STRERROR 39#ifndef HAVE_GAI_STRERROR
40char *gai_strerror(int ecode); 40const char *gai_strerror(int ecode);
41#endif /* !HAVE_GAI_STRERROR */ 41#endif /* !HAVE_GAI_STRERROR */
42 42
43#ifndef HAVE_FREEADDRINFO 43#ifndef HAVE_FREEADDRINFO