aboutsummaryrefslogtreecommitdiffstats
path: root/epan/addr_resolv.c
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2015-03-18 11:25:06 -0700
committerGerald Combs <gerald@wireshark.org>2015-03-18 18:40:46 +0000
commit6b5c71af0da1f213448b14d07e8a9cf209af63b2 (patch)
tree46022d90d5c50ac3eecf436d1def889f7019039b /epan/addr_resolv.c
parent13b3fcbff5a6b2d15f90c3269623e5bcc13c6323 (diff)
Don't cache existing IPv4 and IPv6 hostnames.
In the Qt UI redrawing the packet list redissects our visible packets, which might call add_ipv{4,6}_name, which sets new_resolved_objects = TRUE, which emits the addressResolutionChanged signal, which redraws the packet list, which ... Break out of the loop by checking to see if we've already cached an IPv4 or IPv6 hostname. Change-Id: Icb2841e3453fb98d4cf0ea06a0f49737e2b8f25e Reviewed-on: https://code.wireshark.org/review/7738 Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'epan/addr_resolv.c')
-rw-r--r--epan/addr_resolv.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/epan/addr_resolv.c b/epan/addr_resolv.c
index 11c37c9ce5..9e58205560 100644
--- a/epan/addr_resolv.c
+++ b/epan/addr_resolv.c
@@ -849,6 +849,7 @@ new_ipv4(const guint addr)
hashipv4_t *tp = g_new(hashipv4_t, 1);
tp->addr = addr;
tp->flags = 0;
+ tp->name[0] = '\0';
ip_to_str_buf((const guint8 *)&addr, tp->ip, sizeof(tp->ip));
return tp;
}
@@ -941,6 +942,7 @@ new_ipv6(const struct e_in6_addr *addr)
hashipv6_t *tp = g_new(hashipv6_t,1);
tp->addr = *addr;
tp->flags = 0;
+ tp->name[0] = '\0';
ip6_to_str_buf(addr, tp->ip6);
return tp;
}
@@ -2683,20 +2685,20 @@ add_ipv4_name(const guint addr, const gchar *name)
* Don't add zero-length names; apparently, some resolvers will return
* them if they get them from DNS.
*/
- if (name[0] == '\0')
+ if (!name || name[0] == '\0')
return;
tp = (hashipv4_t *)g_hash_table_lookup(ipv4_hash_table, GUINT_TO_POINTER(addr));
- if (tp) {
- g_strlcpy(tp->name, name, MAXNAMELEN);
- } else {
+ if (!tp) {
tp = new_ipv4(addr);
- g_strlcpy(tp->name, name, MAXNAMELEN);
g_hash_table_insert(ipv4_hash_table, GUINT_TO_POINTER(addr), tp);
}
- g_strlcpy(tp->name, name, MAXNAMELEN);
+ if (g_ascii_strcasecmp(tp->name, name)) {
+ g_strlcpy(tp->name, name, MAXNAMELEN);
+ new_resolved_objects = TRUE;
+ }
tp->flags = tp->flags | TRIED_RESOLVE_ADDRESS;
new_resolved_objects = TRUE;
@@ -2712,25 +2714,24 @@ add_ipv6_name(const struct e_in6_addr *addrp, const gchar *name)
* Don't add zero-length names; apparently, some resolvers will return
* them if they get them from DNS.
*/
- if (name[0] == '\0')
+ if (!name || name[0] == '\0')
return;
tp = (hashipv6_t *)g_hash_table_lookup(ipv6_hash_table, addrp);
- if (tp) {
- g_strlcpy(tp->name, name, MAXNAMELEN);
- } else {
+ if (!tp) {
struct e_in6_addr *addr_key;
addr_key = g_new(struct e_in6_addr,1);
tp = new_ipv6(addrp);
memcpy(addr_key, addrp, 16);
- g_strlcpy(tp->name, name, MAXNAMELEN);
g_hash_table_insert(ipv6_hash_table, addr_key, tp);
}
- g_strlcpy(tp->name, name, MAXNAMELEN);
+ if (g_ascii_strcasecmp(tp->name, name)) {
+ g_strlcpy(tp->name, name, MAXNAMELEN);
+ new_resolved_objects = TRUE;
+ }
tp->flags = tp->flags | TRIED_RESOLVE_ADDRESS;
- new_resolved_objects = TRUE;
} /* add_ipv6_name */