]> andersk Git - gssapi-openssh.git/blobdiff - openssh/openbsd-compat/fake-rfc2553.c
merged OpenSSH 5.1p1 to trunk
[gssapi-openssh.git] / openssh / openbsd-compat / fake-rfc2553.c
index b9ac085c3a3d499112f97c551e2a1fa303b10664..096d9e092e29a9b7dc6219698d0f1d2a93bcfe82 100644 (file)
 
 #include "includes.h"
 
-RCSID("$Id$");
+#include <stdlib.h>
+#include <string.h>
+
+#include <netinet/in.h>
+#include <arpa/inet.h>
 
 #ifndef HAVE_GETNAMEINFO
 int getnameinfo(const struct sockaddr *sa, size_t salen, char *host, 
@@ -47,6 +51,8 @@ int getnameinfo(const struct sockaddr *sa, size_t salen, char *host,
        struct hostent *hp;
        char tmpserv[16];
 
+       if (sa->sa_family != AF_UNSPEC && sa->sa_family != AF_INET)
+               return (EAI_FAMILY);
        if (serv != NULL) {
                snprintf(tmpserv, sizeof(tmpserv), "%d", ntohs(sin->sin_port));
                if (strlcpy(serv, tmpserv, servlen) >= servlen)
@@ -77,7 +83,11 @@ int getnameinfo(const struct sockaddr *sa, size_t salen, char *host,
 #endif /* !HAVE_GETNAMEINFO */
 
 #ifndef HAVE_GAI_STRERROR
+#ifdef HAVE_CONST_GAI_STRERROR_PROTO
+const char *
+#else
 char *
+#endif
 gai_strerror(int err)
 {
        switch (err) {
@@ -87,6 +97,8 @@ gai_strerror(int err)
                return ("memory allocation failure.");
        case EAI_NONAME:
                return ("nodename nor servname provided, or not known");
+       case EAI_FAMILY:
+               return ("ai_family not supported");
        default:
                return ("unknown/invalid error.");
        }
@@ -151,6 +163,9 @@ getaddrinfo(const char *hostname, const char *servname,
        u_long addr;
 
        port = 0;
+       if (hints && hints->ai_family != AF_UNSPEC &&
+           hints->ai_family != AF_INET)
+               return (EAI_FAMILY);
        if (servname != NULL) {
                char *cp;
 
This page took 0.034008 seconds and 4 git commands to generate.