forked from osmocom/wireshark
Restore synchronous name resolution (revert SVN rev52115).
These gethostbyaddr() calls should be changed to getaddrinfo() but only in master. Change-Id: I7e2d31ceb0e072beb7f324336d7b145c3adbe3a0 Reviewed-on: https://code.wireshark.org/review/7402 Reviewed-by: Jeff Morriss <jeff.morriss.ws@gmail.com>
This commit is contained in:
parent
2d4817966e
commit
e5e8af9c71
|
@ -857,6 +857,7 @@ static hashipv4_t *
|
|||
host_lookup(const guint addr, gboolean *found)
|
||||
{
|
||||
hashipv4_t * volatile tp;
|
||||
struct hostent *hostp;
|
||||
|
||||
*found = TRUE;
|
||||
|
||||
|
@ -891,6 +892,25 @@ try_resolv:
|
|||
}
|
||||
#endif /* ASYNC_DNS */
|
||||
|
||||
/*
|
||||
* The Windows "gethostbyaddr()" insists on translating 0.0.0.0 to
|
||||
* the name of the host on which it's running; to work around that
|
||||
* botch, we don't try to translate an all-zero IP address to a host
|
||||
* name.
|
||||
*/
|
||||
if (addr != 0) {
|
||||
/* Use async DNS if possible, else fall back to timeouts,
|
||||
* else call gethostbyaddr and hope for the best
|
||||
*/
|
||||
|
||||
hostp = gethostbyaddr((const char *)&addr, 4, AF_INET);
|
||||
|
||||
if (hostp != NULL && hostp->h_name[0] != '\0') {
|
||||
g_strlcpy(tp->name, hostp->h_name, MAXNAMELEN);
|
||||
return tp;
|
||||
}
|
||||
}
|
||||
|
||||
/* unknown host or DNS timeout */
|
||||
|
||||
}
|
||||
|
@ -922,6 +942,7 @@ host_lookup6(const struct e_in6_addr *addr, gboolean *found)
|
|||
#ifdef HAVE_C_ARES
|
||||
async_dns_queue_msg_t *caqm;
|
||||
#endif /* HAVE_C_ARES */
|
||||
struct hostent *hostp;
|
||||
#endif /* INET6 */
|
||||
|
||||
*found = TRUE;
|
||||
|
@ -971,6 +992,13 @@ try_resolv:
|
|||
}
|
||||
#endif /* HAVE_C_ARES */
|
||||
|
||||
/* Quick hack to avoid DNS/YP timeout */
|
||||
hostp = gethostbyaddr((const char *)addr, sizeof(*addr), AF_INET6);
|
||||
|
||||
if (hostp != NULL && hostp->h_name[0] != '\0') {
|
||||
g_strlcpy(tp->name, hostp->h_name, MAXNAMELEN);
|
||||
return tp;
|
||||
}
|
||||
#endif /* INET6 */
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue