aboutsummaryrefslogtreecommitdiffstats
path: root/epan/addr_resolv.c
diff options
context:
space:
mode:
authorChristopher Maynard <Christopher.Maynard@igt.com>2015-06-06 20:04:42 -0400
committerAnders Broman <a.broman58@gmail.com>2015-06-09 04:09:52 +0000
commit41ac67cbb218d9d7da4bd7d767b12c03a0096b5b (patch)
treee04af53029e067e86db6dad99420d329f050f29e /epan/addr_resolv.c
parente28339e59001baf9bb3aa02e29b931b316d07e1c (diff)
Fix insertion of subnets read from the subnets file: append to the *end* of
the list. The patch ensures that non-duplicate subnets are appended to the end of the list rather than as the second element, which if there had been a second element previously, the memory for it was effectively leaked. It also allows /32 "subnets", even though arguably the hosts file should be used instead, but now the test in read_subnets_file() matches the assert in subnet_entry_set(). Bug: 11247 Change-Id: I54bf1cbb34edfcf410aa634043a377c27091df51 Reviewed-on: https://code.wireshark.org/review/8802 Petri-Dish: Jeff Morriss <jeff.morriss.ws@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Jeff Morriss <jeff.morriss.ws@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/addr_resolv.c')
-rwxr-xr-x[-rw-r--r--]epan/addr_resolv.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/epan/addr_resolv.c b/epan/addr_resolv.c
index 37dd4b1452..c580311b1a 100644..100755
--- a/epan/addr_resolv.c
+++ b/epan/addr_resolv.c
@@ -2087,8 +2087,8 @@ read_hosts_file (const char *hostspath, gboolean store_entries)
/*
* Add the aliases, too, if there are any.
* XXX - except we only store the last one added. The name
- * resolver returns the first name in the hosts file, we should
- * too.
+ * resolver returns the first name in the hosts file, we should
+ * too.
*/
while ((cp = strtok(NULL, " \t")) != NULL) {
if (is_ipv6) {
@@ -2265,7 +2265,7 @@ read_subnets_file (const char *subnetspath)
}
mask_length = atoi(cp2);
- if (0 >= mask_length || mask_length > 31) {
+ if (0 >= mask_length || mask_length > 32) {
continue; /* invalid mask length */
}
@@ -2352,13 +2352,19 @@ subnet_entry_set(guint32 subnet_addr, const guint32 mask_length, const gchar* na
}
if (NULL != (tp = entry->subnet_addresses[hash_idx])) {
- if (tp->addr == subnet_addr) {
- return; /* XXX provide warning that an address was repeated? */
- } else {
- sub_net_hashipv4_t * new_tp = g_new(sub_net_hashipv4_t, 1);
- tp->next = new_tp;
- tp = new_tp;
+ sub_net_hashipv4_t * new_tp;
+
+ while (tp->next) {
+ if (tp->addr == subnet_addr) {
+ return; /* XXX provide warning that an address was repeated? */
+ } else {
+ tp = tp->next;
+ }
}
+
+ new_tp = g_new(sub_net_hashipv4_t, 1);
+ tp->next = new_tp;
+ tp = new_tp;
} else {
tp = entry->subnet_addresses[hash_idx] = g_new(sub_net_hashipv4_t, 1);
}