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;
|
break;
|
||||||
}
|
}
|
||||||
bp += n;
|
bp += n;
|
||||||
_map_v4v6_hostent(he, &bp, &ep);
|
_map_v4v6_hostent(he, &bp, ep);
|
||||||
}
|
}
|
||||||
h_errno = NETDB_SUCCESS;
|
h_errno = NETDB_SUCCESS;
|
||||||
return 0;
|
return 0;
|
||||||
@ -425,7 +425,7 @@ gethostanswer(const querybuf *answer, int anslen, const char *qname, int qtype,
|
|||||||
bp += n;
|
bp += n;
|
||||||
}
|
}
|
||||||
if (_res.options & RES_USE_INET6)
|
if (_res.options & RES_USE_INET6)
|
||||||
_map_v4v6_hostent(he, &bp, &ep);
|
_map_v4v6_hostent(he, &bp, ep);
|
||||||
h_errno = NETDB_SUCCESS;
|
h_errno = NETDB_SUCCESS;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ gethostbyname_internal(const char *name, int af, struct hostent *he,
|
|||||||
hed->h_addr_ptrs[1] = NULL;
|
hed->h_addr_ptrs[1] = NULL;
|
||||||
he->h_addr_list = hed->h_addr_ptrs;
|
he->h_addr_list = hed->h_addr_ptrs;
|
||||||
if (_res.options & RES_USE_INET6)
|
if (_res.options & RES_USE_INET6)
|
||||||
_map_v4v6_hostent(he, &bp, &ep);
|
_map_v4v6_hostent(he, &bp, ep);
|
||||||
h_errno = NETDB_SUCCESS;
|
h_errno = NETDB_SUCCESS;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -79,31 +79,25 @@ typedef union {
|
|||||||
} align;
|
} align;
|
||||||
|
|
||||||
void
|
void
|
||||||
_map_v4v6_address(src, dst)
|
_map_v4v6_address(const char *src, char *dst)
|
||||||
const char *src;
|
|
||||||
char *dst;
|
|
||||||
{
|
{
|
||||||
u_char *p = (u_char *)dst;
|
u_char *p = (u_char *)dst;
|
||||||
char tmp[INADDRSZ];
|
char tmp[NS_INADDRSZ];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Stash a temporary copy so our caller can update in place. */
|
/* 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. */
|
/* Mark this ipv6 addr as a mapped ipv4. */
|
||||||
for (i = 0; i < 10; i++)
|
for (i = 0; i < 10; i++)
|
||||||
*p++ = 0x00;
|
*p++ = 0x00;
|
||||||
*p++ = 0xff;
|
*p++ = 0xff;
|
||||||
*p++ = 0xff;
|
*p++ = 0xff;
|
||||||
/* Retrieve the saved copy and we're done. */
|
/* Retrieve the saved copy and we're done. */
|
||||||
bcopy(tmp, (void*)p, INADDRSZ);
|
memcpy((void*)p, tmp, NS_INADDRSZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_map_v4v6_hostent(hp, bpp, epp)
|
_map_v4v6_hostent(struct hostent *hp, char **bpp, char *ep) {
|
||||||
struct hostent *hp;
|
|
||||||
char **bpp;
|
|
||||||
char **epp;
|
|
||||||
{
|
|
||||||
char **ap;
|
char **ap;
|
||||||
|
|
||||||
if (hp->h_addrtype != AF_INET || hp->h_length != INADDRSZ)
|
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_addrtype = AF_INET6;
|
||||||
hp->h_length = IN6ADDRSZ;
|
hp->h_length = IN6ADDRSZ;
|
||||||
for (ap = hp->h_addr_list; *ap; ap++) {
|
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)) {
|
if (i != 0)
|
||||||
/* Out of memory. Truncate address list here. XXX */
|
i = sizeof(align) - i;
|
||||||
|
|
||||||
|
if ((ep - *bpp) < (i + IN6ADDRSZ)) {
|
||||||
|
/* Out of memory. Truncate address list here. */
|
||||||
*ap = NULL;
|
*ap = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ void _endnethtent(struct netent_data *);
|
|||||||
struct hostent *_gethostbynisaddr(const char *, int, int);
|
struct hostent *_gethostbynisaddr(const char *, int, int);
|
||||||
struct hostent *_gethostbynisname(const char *, int);
|
struct hostent *_gethostbynisname(const char *, int);
|
||||||
void _map_v4v6_address(const char *, char *);
|
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 _sethostdnsent(int);
|
||||||
void _sethosthtent(int, struct hostent_data *);
|
void _sethosthtent(int, struct hostent_data *);
|
||||||
void _setnetdnsent(int);
|
void _setnetdnsent(int);
|
||||||
|
Loading…
Reference in New Issue
Block a user