Changes in tonights snapshot

Darren Tucker dtucker at zip.com.au
Wed May 14 19:45:19 EST 2003


Damien Miller wrote:
> Darren Tucker wrote:
> > How about setting "ai->ai_socktype = SOCK_STREAM;" to malloc_ai()?  This
> > works for me.
> 
> If hints->ai_socktype and hints->ai_protocol are set we should use them
> first, otherwise you are correct*.

How's the attached patch?

-- 
Darren Tucker (dtucker at zip.com.au)
GPG key 8FF4FA69 / D9A3 86E9 7EEE AF4B B2D4  37C9 C982 80C7 8FF4 FA69
    Good judgement comes with experience. Unfortunately, the experience
usually comes from bad judgement.
-------------- next part --------------
Index: openbsd-compat/fake-getaddrinfo.c
===================================================================
RCS file: /var/cvs/openssh/openbsd-compat/fake-getaddrinfo.c,v
retrieving revision 1.5
diff -u -r1.5 fake-getaddrinfo.c
--- openbsd-compat/fake-getaddrinfo.c	24 Mar 2003 02:35:59 -0000	1.5
+++ openbsd-compat/fake-getaddrinfo.c	14 May 2003 09:38:46 -0000
@@ -41,7 +41,7 @@
 #endif /* !HAVE_FREEADDRINFO */
 
 #ifndef HAVE_GETADDRINFO
-static struct addrinfo *malloc_ai(int port, u_long addr)
+static struct addrinfo *malloc_ai(int port, u_long addr, struct addrinfo *hints)
 {
 	struct addrinfo *ai;
 
@@ -59,6 +59,14 @@
 	((struct sockaddr_in *)(ai)->ai_addr)->sin_port = port;
 	((struct sockaddr_in *)(ai)->ai_addr)->sin_addr.s_addr = addr;
 	
+	if (hints->ai_socktype)
+		ai->ai_socktype = hints->ai_socktype;
+	else
+		ai->ai_socktype = SOCK_STREAM;
+
+	if (hints->ai_protocol)
+		ai->ai_protocol = hints->ai_protocol;
+
 	return(ai);
 }
 
@@ -90,21 +98,21 @@
 		addr = htonl(0x00000000);
 		if (hostname && inet_aton(hostname, &in) != 0)
 			addr = in.s_addr;
-		if (NULL != (*res = malloc_ai(port, addr)))
+		if (NULL != (*res = malloc_ai(port, addr, hints)))
 			return 0;
 		else
 			return EAI_MEMORY;
 	}
 		
 	if (!hostname) {
-		if (NULL != (*res = malloc_ai(port, htonl(0x7f000001))))
+		if (NULL != (*res = malloc_ai(port, htonl(0x7f000001), hints)))
 			return 0;
 		else
 			return EAI_MEMORY;
 	}
 	
 	if (inet_aton(hostname, &in)) {
-		if (NULL != (*res = malloc_ai(port, in.s_addr)))
+		if (NULL != (*res = malloc_ai(port, in.s_addr, hints)))
 			return 0;
 		else
 			return EAI_MEMORY;
@@ -113,7 +121,8 @@
 	hp = gethostbyname(hostname);
 	if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) {
 		for (i = 0; hp->h_addr_list[i]; i++) {
-			cur = malloc_ai(port, ((struct in_addr *)hp->h_addr_list[i])->s_addr);
+			cur = malloc_ai(port,
+			    ((struct in_addr *)hp->h_addr_list[i])->s_addr, hints);
 			if (cur == NULL) {
 				if (*res)
 					freeaddrinfo(*res);


More information about the openssh-unix-dev mailing list