convert IPv4 mapped address (::ffff:10.1.1.1) into real IPv4 address
before touching it. IPv4 mapped address complicates too many things in FTP protocol handling.
This commit is contained in:
parent
60e2ae70e5
commit
288fc74e2e
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: extern.h,v 1.54 2000/05/01 10:35:17 lukem Exp $ */
|
||||
/* $NetBSD: extern.h,v 1.55 2000/05/29 14:57:27 itojun Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996-2000 The NetBSD Foundation, Inc.
|
||||
|
@ -102,12 +102,14 @@
|
|||
|
||||
struct sockaddr;
|
||||
struct tm;
|
||||
struct addrinfo;
|
||||
|
||||
void abort_remote(FILE *);
|
||||
void abort_squared(int);
|
||||
void abortpt(int);
|
||||
void abortxfer(int);
|
||||
void account(int, char **);
|
||||
void ai_unmapped(struct addrinfo *);
|
||||
void alarmtimer(int);
|
||||
int another(int *, char ***, const char *);
|
||||
int auto_fetch(int, char **);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: fetch.c,v 1.112 2000/05/25 15:35:51 itojun Exp $ */
|
||||
/* $NetBSD: fetch.c,v 1.113 2000/05/29 14:57:27 itojun Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997-2000 The NetBSD Foundation, Inc.
|
||||
|
@ -38,7 +38,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: fetch.c,v 1.112 2000/05/25 15:35:51 itojun Exp $");
|
||||
__RCSID("$NetBSD: fetch.c,v 1.113 2000/05/29 14:57:27 itojun Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
|
@ -733,6 +733,10 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
|
|||
|
||||
s = -1;
|
||||
for (res = res0; res; res = res->ai_next) {
|
||||
/*
|
||||
* see comment in hookup()
|
||||
*/
|
||||
ai_unmapped(res);
|
||||
if (getnameinfo(res->ai_addr, res->ai_addrlen,
|
||||
hbuf, sizeof(hbuf), NULL, 0,
|
||||
NI_NUMERICHOST) != 0)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ftp.c,v 1.95 2000/05/01 10:35:18 lukem Exp $ */
|
||||
/* $NetBSD: ftp.c,v 1.96 2000/05/29 14:57:28 itojun Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996-2000 The NetBSD Foundation, Inc.
|
||||
|
@ -103,7 +103,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: ftp.c,v 1.95 2000/05/01 10:35:18 lukem Exp $");
|
||||
__RCSID("$NetBSD: ftp.c,v 1.96 2000/05/29 14:57:28 itojun Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -215,6 +215,13 @@ hookup(char *host, char *port)
|
|||
hostname = hostnamebuf;
|
||||
|
||||
for (res = res0; res; res = res->ai_next) {
|
||||
/*
|
||||
* make sure that ai_addr is NOT an IPv4 mapped address.
|
||||
* IPv4 mapped address complicates too many things in FTP
|
||||
* protocol handling, as FTP protocol is defined differently
|
||||
* between IPv4 and IPv6.
|
||||
*/
|
||||
ai_unmapped(res);
|
||||
#if 0 /*old behavior*/
|
||||
if (res != res0) /* not on the first address */
|
||||
#else
|
||||
|
@ -2183,3 +2190,30 @@ abort_remote(FILE *din)
|
|||
}
|
||||
(void)getreply(0);
|
||||
}
|
||||
|
||||
void
|
||||
ai_unmapped(struct addrinfo *ai)
|
||||
{
|
||||
struct sockaddr_in6 *sin6;
|
||||
struct sockaddr_in sin;
|
||||
|
||||
if (ai->ai_family != AF_INET6)
|
||||
return;
|
||||
if (ai->ai_addrlen != sizeof(struct sockaddr_in6) ||
|
||||
sizeof(sin) > ai->ai_addrlen)
|
||||
return;
|
||||
sin6 = (struct sockaddr_in6 *)ai->ai_addr;
|
||||
if (!IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr))
|
||||
return;
|
||||
|
||||
memset(&sin, 0, sizeof(sin));
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_len = sizeof(struct sockaddr_in);
|
||||
memcpy(&sin.sin_addr, &sin6->sin6_addr.s6_addr[12],
|
||||
sizeof(sin.sin_addr));
|
||||
sin.sin_port = sin6->sin6_port;
|
||||
|
||||
ai->ai_family = AF_INET;
|
||||
memcpy(ai->ai_addr, &sin, sin.sin_len);
|
||||
ai->ai_addrlen = sin.sin_len;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue