diff options
author | Peter Wu <peter@lekensteyn.nl> | 2018-04-30 18:26:21 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2018-05-01 10:27:53 +0000 |
commit | 2ed9115a4b4bca00721ec1d40018835b3e844f84 (patch) | |
tree | 99f4a8263a91c446a9c257feab9fd1fe6b68a1a5 | |
parent | 82824fd3940b304106c71f14c6975be60b7a75da (diff) |
prefs: fix crash when setting certain obsolete port preferences
Loading an old Wireshark profile with certain deprecated preferences
could result in a crash due to type confusion. If the new preference was
a range type, then four bytes of the pointer (address) to the range was
overwritten with the numeric value of the deprecated preference.
Minimal reproducer:
tshark -opgm.udp.encap_ucast_port:0 -r ../test/captures/empty.pcap
Bug: 14316
Change-Id: Ia8dc24f81f6b2e6494448dadffe810606765cb9e
Fixes: v2.3.0rc0-971-g268841f3e0 ("Combine Decode As and port preferences for tcp.port dissector table.")
Reviewed-on: https://code.wireshark.org/review/27226
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r-- | epan/prefs.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/epan/prefs.c b/epan/prefs.c index b7457f9bde..11f9990a7e 100644 --- a/epan/prefs.c +++ b/epan/prefs.c @@ -5194,10 +5194,17 @@ deprecated_port_pref(gchar *pref_name, const gchar *value) module = prefs_find_module(port_prefs[i].module_name); pref = prefs_find_preference(module, port_prefs[i].table_name); - if (pref != NULL) - { + if (pref != NULL) { module->prefs_changed_flags |= prefs_get_effect_flags(pref); - *pref->varp.uint = uval; + if (pref->type == PREF_DECODE_AS_UINT) { + *pref->varp.uint = uval; + } else if (pref->type == PREF_DECODE_AS_RANGE) { + // The legacy preference was a port number, but the new + // preference is a port range. Add to existing range. + if (uval) { + prefs_range_add_value(pref, uval); + } + } } /* If the value is zero, it wouldn't add to the Decode As tables */ |