Skip to content

Commit

Permalink
- Update fake-rfc2553.{c,h} from OpenSSH 5.5p1
Browse files Browse the repository at this point in the history
--HG--
extra : convert_revision : 4b90e96a8a8afcc9feafc59cb47592a4a6d1cc30
  • Loading branch information
mkj committed Jul 21, 2010
1 parent 27fddd2 commit aabe067
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 10 deletions.
18 changes: 14 additions & 4 deletions fake-rfc2553.c
@@ -1,7 +1,6 @@
/* Taken for Dropbear from OpenSSH 5.5p1 */

/*
*
* Taken from OpenSSH 3.8.1p1
*
* Copyright (C) 2000-2003 Damien Miller. All rights reserved.
* Copyright (C) 1999 WIDE Project. All rights reserved.
*
Expand Down Expand Up @@ -40,7 +39,11 @@

#include "includes.h"

/* RCSID("$.Id: fake-rfc2553.c,v 1.5 2003/09/22 02:08:23 dtucker Exp $");*/
#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,
Expand All @@ -50,6 +53,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)
Expand Down Expand Up @@ -94,6 +99,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.");
}
Expand Down Expand Up @@ -158,6 +165,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;

Expand Down
27 changes: 21 additions & 6 deletions fake-rfc2553.h
@@ -1,6 +1,6 @@
/* Taken from OpenSSH 3.8.1p1 */
/* Taken for Dropbear from OpenSSH 5.5p1 */

/* $.Id: fake-rfc2553.h,v 1.9 2004/03/10 10:06:33 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.
Expand Down Expand Up @@ -43,6 +43,10 @@
#define _FAKE_RFC2553_H

#include "includes.h"
#include <sys/types.h>
#if defined(HAVE_NETDB_H)
# include <netdb.h>
#endif

/*
* First, socket and INET6 related definitions
Expand Down Expand Up @@ -75,6 +79,7 @@ struct sockaddr_in6 {
u_int16_t sin6_port;
u_int32_t sin6_flowinfo;
struct in6_addr sin6_addr;
u_int32_t sin6_scope_id;
};
#endif /* !HAVE_STRUCT_SOCKADDR_IN6 */

Expand Down Expand Up @@ -115,9 +120,19 @@ struct sockaddr_in6 {
#endif /* !NI_MAXHOST */

#ifndef EAI_NODATA
# define EAI_NODATA 1
# define EAI_MEMORY 2
# define EAI_NONAME 3
# define EAI_NODATA (INT_MAX - 1)
#endif
#ifndef EAI_MEMORY
# define EAI_MEMORY (INT_MAX - 2)
#endif
#ifndef EAI_NONAME
# define EAI_NONAME (INT_MAX - 3)
#endif
#ifndef EAI_SYSTEM
# define EAI_SYSTEM (INT_MAX - 4)
#endif
#ifndef EAI_FAMILY
# define EAI_FAMILY (INT_MAX - 5)
#endif

#ifndef HAVE_STRUCT_ADDRINFO
Expand All @@ -143,7 +158,7 @@ int getaddrinfo(const char *, const char *,
#endif /* !HAVE_GETADDRINFO */

#if !defined(HAVE_GAI_STRERROR) && !defined(HAVE_CONST_GAI_STRERROR_PROTO)
#define gai_strerror(a) (ssh_gai_strerror(a))
#define gai_strerror(a) (_ssh_compat_gai_strerror(a))
char *gai_strerror(int);
#endif /* !HAVE_GAI_STRERROR */

Expand Down

0 comments on commit aabe067

Please sign in to comment.