1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
$NetBSD: patch-bi,v 1.1 2006/11/02 12:31:58 kivinen Exp $
--- lib/sshutil/sshnet/sshunixtcp.c.orig 2003-12-03 15:17:31.000000000 +0200
+++ lib/sshutil/sshnet/sshunixtcp.c
@@ -1459,7 +1459,6 @@ char *ssh_tcp_get_host_by_addr_sync(cons
#else /* VXWORKS */
unsigned char outbuf[16];
size_t outbuflen = 16;
- struct in_addr in_addr;
struct hostent *hp;
char *name;
int i;
@@ -1467,8 +1466,16 @@ char *ssh_tcp_get_host_by_addr_sync(cons
if (!ssh_inet_strtobin(addr, outbuf, &outbuflen))
return NULL;
- memmove(&in_addr.s_addr, outbuf, outbuflen);
- hp = gethostbyaddr((char *)&in_addr, sizeof(struct in_addr), AF_INET);
+#ifdef AF_INET6
+ hp = gethostbyaddr((char *)outbuf, outbuflen,
+ (outbuflen == 16) ? AF_INET6 : AF_INET);
+#else /* AF_INET6 */
+ if (outbuflen == 16)
+ return NULL;
+ hp = gethostbyaddr((char *)outbuf, outbuflen,
+ AF_INET);
+#endif /* AF_INET6 */
+
if (!hp)
return NULL;
@@ -1491,7 +1498,8 @@ char *ssh_tcp_get_host_by_addr_sync(cons
/* Look for the address from the list of addresses. */
for (i = 0; hp->h_addr_list[i]; i++)
- if (memcmp(hp->h_addr_list[i], &in_addr, sizeof(in_addr)) == 0)
+ if (hp->h_length == outbuflen &&
+ memcmp(hp->h_addr_list[i], outbuf, outbuflen) == 0)
break;
/* If we reached the end of the list, the address was not there. */
if (!hp->h_addr_list[i])
|