sync _map_v4v6_host*() with bind9's. it treats align better bit.
Obtained from: BIND9
This commit is contained in:
parent
b8ab0f4506
commit
850bc9af6b
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 (*epp - *bpp < (i + IN6ADDRSZ)) {
|
||||
/* Out of memory. Truncate address list here. XXX */
|
||||
if (i != 0)
|
||||
i = sizeof(align) - i;
|
||||
|
||||
if ((ep - *bpp) < (i + IN6ADDRSZ)) {
|
||||
/* Out of memory. Truncate address list here. */
|
||||
*ap = NULL;
|
||||
return;
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user