aboutsummaryrefslogtreecommitdiffstats
path: root/epan/packet.c
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2019-04-21 03:16:12 +0100
committerAnders Broman <a.broman58@gmail.com>2019-04-22 16:32:32 +0000
commit5076e53ffb2b39d5d9ac2dcf6f2fd626bf2cafd7 (patch)
tree7617b7e55f6c2ae8eea7bd8ad9d1f54136d428e8 /epan/packet.c
parentc802a83363b22dfa9417707f4714128442c4148e (diff)
packet: ensure pinfo->curr_layer_num does not depend on tree
The TLS dissector relies on a stable value for pinfo->curr_layer_num between passes to enable handshake reassembly and decryption. A mismatch could occur if the subdissector accepted the data (len is non-zero), but did not add any tree items (tree->tree_data->count remains unchanged). The original change added the check for tree->tree_data->count in order to remove protocol names that are not visible in the tree. This could for example occur when the HTTP dissector accepts the data but requests more data for reassembly. This desire to hide protocols is understandable, so simply reverting the change would not be ok. Checking pinfo->desegment_offset is also not stable. So that leaves the current approach. Change-Id: I247adafbaa6d23ab9397eadacabaed9e1bfde997 Ping-Bug: 15625 Fixes: v2.5.0rc0-1206-gcd90f732a1 ("Improve frame.protocols accuracy.") Reviewed-on: https://code.wireshark.org/review/32919 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Pascal Quantin <pascal@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/packet.c')
-rw-r--r--epan/packet.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/epan/packet.c b/epan/packet.c
index dcf6f31741..62b102da33 100644
--- a/epan/packet.c
+++ b/epan/packet.c
@@ -798,7 +798,15 @@ call_dissector_work(dissector_handle_t handle, tvbuff_t *tvb, packet_info *pinfo
* tree. Remove it.
*/
while (wmem_list_count(pinfo->layers) > saved_layers_len) {
- pinfo->curr_layer_num--;
+ if (len == 0) {
+ /*
+ * Only reduce the layer number if the dissector
+ * rejected the data. Since tree can be NULL on
+ * the first pass, we cannot check it or it will
+ * break dissectors that rely on a stable value.
+ */
+ pinfo->curr_layer_num--;
+ }
wmem_list_remove_frame(pinfo->layers, wmem_list_tail(pinfo->layers));
}
}
@@ -2756,7 +2764,15 @@ dissector_try_heuristic(heur_dissector_list_t sub_dissectors, tvbuff_t *tvb,
* items to the tree so remove it from the list.
*/
while (wmem_list_count(pinfo->layers) > saved_layers_len) {
- pinfo->curr_layer_num--;
+ if (len == 0) {
+ /*
+ * Only reduce the layer number if the dissector
+ * rejected the data. Since tree can be NULL on
+ * the first pass, we cannot check it or it will
+ * break dissectors that rely on a stable value.
+ */
+ pinfo->curr_layer_num--;
+ }
wmem_list_remove_frame(pinfo->layers, wmem_list_tail(pinfo->layers));
}
}