(krb5_parse_address): use getaddrinfo
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@7488 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -506,7 +506,10 @@ krb5_parse_address(krb5_context context,
|
|||||||
const char *string,
|
const char *string,
|
||||||
krb5_addresses *addresses)
|
krb5_addresses *addresses)
|
||||||
{
|
{
|
||||||
int i;
|
int i, n;
|
||||||
|
struct addrinfo *ai, *a;
|
||||||
|
int error;
|
||||||
|
|
||||||
for(i = 0; i < num_addrs; i++) {
|
for(i = 0; i < num_addrs; i++) {
|
||||||
if(at[i].parse_addr) {
|
if(at[i].parse_addr) {
|
||||||
krb5_address a;
|
krb5_address a;
|
||||||
@@ -518,24 +521,24 @@ krb5_parse_address(krb5_context context,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_GETHOSTBYNAME
|
error = getaddrinfo (string, NULL, NULL, &ai);
|
||||||
{
|
if (error)
|
||||||
char **a;
|
return -1;
|
||||||
struct hostent *hp = gethostbyname(string);
|
|
||||||
struct addr_operations *aop;
|
n = 0;
|
||||||
if(hp == NULL)
|
for (a = ai; a != NULL; a = a->ai_next)
|
||||||
return -1;
|
++n;
|
||||||
for(a = hp->h_addr_list; *a; a++);
|
|
||||||
ALLOC_SEQ(addresses, a - hp->h_addr_list);
|
ALLOC_SEQ(addresses, n);
|
||||||
|
|
||||||
aop = find_af(hp->h_addrtype);
|
for (a = ai, i = 0; a != NULL; a = a->ai_next, ++i) {
|
||||||
for(a = hp->h_addr_list; *a; a++) {
|
struct addr_operations *aop = find_af (ai->ai_family);
|
||||||
addresses->val[a - hp->h_addr_list].addr_type = aop->atype;
|
|
||||||
krb5_data_copy(&addresses->val[a - hp->h_addr_list].address,
|
addresses->val[i].addr_type = aop->atype;
|
||||||
*a,
|
krb5_data_copy (&addresses->val[i].address,
|
||||||
hp->h_length);
|
ai->ai_addr,
|
||||||
}
|
ai->ai_addrlen);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
#endif
|
freeaddrinfo (ai);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user