From c4657ef1818c67e91115389a69ef783412fd54b7 Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Mon, 14 Jul 2008 21:37:36 +1000 Subject: [PATCH] - (djm) [openbsd-compat/fake-rfc2553.c openbsd-compat/fake-rfc2553.h] return EAI_FAMILY when trying to lookup unsupported address family; from vinschen AT redhat.com --- ChangeLog | 5 ++++- openbsd-compat/fake-rfc2553.c | 7 +++++++ openbsd-compat/fake-rfc2553.h | 5 ++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d60f16c9a..b72d47203 100644 --- a/ChangeLog +++ b/ChangeLog @@ -42,6 +42,9 @@ [scp.1] better description for -i flag: s/RSA authentication/public key authentication/ + - (djm) [openbsd-compat/fake-rfc2553.c openbsd-compat/fake-rfc2553.h] + return EAI_FAMILY when trying to lookup unsupported address family; + from vinschen AT redhat.com 20080711 - (djm) OpenBSD CVS Sync @@ -4667,4 +4670,4 @@ OpenServer 6 and add osr5bigcrypt support so when someone migrates passwords between UnixWare and OpenServer they will still work. OK dtucker@ -$Id: ChangeLog,v 1.5083 2008/07/14 02:12:52 djm Exp $ +$Id: ChangeLog,v 1.5084 2008/07/14 11:37:36 djm Exp $ diff --git a/openbsd-compat/fake-rfc2553.c b/openbsd-compat/fake-rfc2553.c index b6ea3d21e..096d9e092 100644 --- a/openbsd-compat/fake-rfc2553.c +++ b/openbsd-compat/fake-rfc2553.c @@ -51,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) @@ -95,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."); } @@ -159,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; diff --git a/openbsd-compat/fake-rfc2553.h b/openbsd-compat/fake-rfc2553.h index 13240970f..3e9090fc8 100644 --- a/openbsd-compat/fake-rfc2553.h +++ b/openbsd-compat/fake-rfc2553.h @@ -1,4 +1,4 @@ -/* $Id: fake-rfc2553.h,v 1.15 2008/06/10 13:52:51 dtucker Exp $ */ +/* $Id: fake-rfc2553.h,v 1.16 2008/07/14 11:37:37 djm Exp $ */ /* * Copyright (C) 2000-2003 Damien Miller. All rights reserved. @@ -129,6 +129,9 @@ struct sockaddr_in6 { #ifndef EAI_SYSTEM # define EAI_SYSTEM (INT_MAX - 4) #endif +#ifndef EAI_FAMILY +# define EAI_FAMILY (INT_MAX - 5) +#endif #ifndef HAVE_STRUCT_ADDRINFO struct addrinfo {