summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorume <ume@FreeBSD.org>2005-04-28 18:52:40 +0000
committerume <ume@FreeBSD.org>2005-04-28 18:52:40 +0000
commitd8dbaeb308e2bb88b0eebab250c74380781bee0a (patch)
treee60df6bf9d1467366a82c911c6a5eed5bf54adaa
parent412b7128e447d4c3ccd08e6a8115cd65c287dc28 (diff)
downloadFreeBSD-src-d8dbaeb308e2bb88b0eebab250c74380781bee0a.zip
FreeBSD-src-d8dbaeb308e2bb88b0eebab250c74380781bee0a.tar.gz
sync _map_v4v6_host*() with bind9's. it treats align better bit.
Obtained from: BIND9
-rw-r--r--lib/libc/net/gethostbydns.c4
-rw-r--r--lib/libc/net/gethostnamadr.c2
-rw-r--r--lib/libc/net/map_v4v6.c25
-rw-r--r--lib/libc/net/netdb_private.h2
4 files changed, 15 insertions, 18 deletions
diff --git a/lib/libc/net/gethostbydns.c b/lib/libc/net/gethostbydns.c
index 63bda78..1077bb8 100644
--- a/lib/libc/net/gethostbydns.c
+++ b/lib/libc/net/gethostbydns.c
@@ -348,7 +348,7 @@ gethostanswer(const querybuf *answer, int anslen, const char *qname, int qtype,
break;
}
bp += n;
- _map_v4v6_hostent(he, &bp, &ep);
+ _map_v4v6_hostent(he, &bp, ep);
}
h_errno = NETDB_SUCCESS;
return 0;
@@ -425,7 +425,7 @@ gethostanswer(const querybuf *answer, int anslen, const char *qname, int qtype,
bp += n;
}
if (_res.options & RES_USE_INET6)
- _map_v4v6_hostent(he, &bp, &ep);
+ _map_v4v6_hostent(he, &bp, ep);
h_errno = NETDB_SUCCESS;
return 0;
}
diff --git a/lib/libc/net/gethostnamadr.c b/lib/libc/net/gethostnamadr.c
index 6c94d98..78b3a7a 100644
--- a/lib/libc/net/gethostnamadr.c
+++ b/lib/libc/net/gethostnamadr.c
@@ -205,7 +205,7 @@ gethostbyname_internal(const char *name, int af, struct hostent *he,
hed->h_addr_ptrs[1] = NULL;
he->h_addr_list = hed->h_addr_ptrs;
if (_res.options & RES_USE_INET6)
- _map_v4v6_hostent(he, &bp, &ep);
+ _map_v4v6_hostent(he, &bp, ep);
h_errno = NETDB_SUCCESS;
return 0;
}
diff --git a/lib/libc/net/map_v4v6.c b/lib/libc/net/map_v4v6.c
index c8aaa3a..dbbddc0 100644
--- a/lib/libc/net/map_v4v6.c
+++ b/lib/libc/net/map_v4v6.c
@@ -79,31 +79,25 @@ typedef union {
} align;
void
-_map_v4v6_address(src, dst)
- const char *src;
- char *dst;
+_map_v4v6_address(const char *src, char *dst)
{
u_char *p = (u_char *)dst;
- char tmp[INADDRSZ];
+ char tmp[NS_INADDRSZ];
int i;
/* Stash a temporary copy so our caller can update in place. */
- bcopy(src, tmp, INADDRSZ);
+ memcpy(tmp, src, NS_INADDRSZ);
/* Mark this ipv6 addr as a mapped ipv4. */
for (i = 0; i < 10; i++)
*p++ = 0x00;
*p++ = 0xff;
*p++ = 0xff;
/* Retrieve the saved copy and we're done. */
- bcopy(tmp, (void*)p, INADDRSZ);
+ memcpy((void*)p, tmp, NS_INADDRSZ);
}
void
-_map_v4v6_hostent(hp, bpp, epp)
- struct hostent *hp;
- char **bpp;
- char **epp;
-{
+_map_v4v6_hostent(struct hostent *hp, char **bpp, char *ep) {
char **ap;
if (hp->h_addrtype != AF_INET || hp->h_length != INADDRSZ)
@@ -111,10 +105,13 @@ _map_v4v6_hostent(hp, bpp, epp)
hp->h_addrtype = AF_INET6;
hp->h_length = IN6ADDRSZ;
for (ap = hp->h_addr_list; *ap; ap++) {
- int i = sizeof(align) - ((u_long)*bpp % sizeof(align));
+ int i = (u_long)*bpp % sizeof(align);
+
+ if (i != 0)
+ i = sizeof(align) - i;
- if (*epp - *bpp < (i + IN6ADDRSZ)) {
- /* Out of memory. Truncate address list here. XXX */
+ if ((ep - *bpp) < (i + IN6ADDRSZ)) {
+ /* Out of memory. Truncate address list here. */
*ap = NULL;
return;
}
diff --git a/lib/libc/net/netdb_private.h b/lib/libc/net/netdb_private.h
index aa28ee7..e5a55ec 100644
--- a/lib/libc/net/netdb_private.h
+++ b/lib/libc/net/netdb_private.h
@@ -140,7 +140,7 @@ void _endnethtent(struct netent_data *);
struct hostent *_gethostbynisaddr(const char *, int, int);
struct hostent *_gethostbynisname(const char *, int);
void _map_v4v6_address(const char *, char *);
-void _map_v4v6_hostent(struct hostent *, char **, char **);
+void _map_v4v6_hostent(struct hostent *, char **, char *);
void _sethostdnsent(int);
void _sethosthtent(int, struct hostent_data *);
void _setnetdnsent(int);
OpenPOWER on IntegriCloud