aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-daap.c
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2020-04-14 16:04:09 -0700
committerAnders Broman <a.broman58@gmail.com>2020-04-15 04:09:08 +0000
commit6a8c1b9b932d70428356ca35da653d943e799546 (patch)
tree514f7bcd3ea890fb0cc9bcda5b87ef5b07463463 /epan/dissectors/packet-daap.c
parente9e90f67b7ef5c3d7b262817d76b817de23e89b6 (diff)
epan: Add p_[gs]et_proto_depth.
Add convenience routines for getting and setting a per-protocol, per-packet depth value, which can be used to limit recursion, nesting, cycling, etc. Use them in the BACapp, DAAP, Mongo, VLAN, and WBXML dissectors. Change-Id: I172514828169253ae7fcf9162c9d7eeb3041ff9c Reviewed-on: https://code.wireshark.org/review/36846 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-daap.c')
-rw-r--r--epan/dissectors/packet-daap.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/epan/dissectors/packet-daap.c b/epan/dissectors/packet-daap.c
index acb01931da..255be50859 100644
--- a/epan/dissectors/packet-daap.c
+++ b/epan/dissectors/packet-daap.c
@@ -15,6 +15,7 @@
#include <epan/exceptions.h>
#include <wsutil/str_util.h>
#include <epan/expert.h>
+#include <epan/proto_data.h>
#include "packet-http.h"
#define TCP_PORT_DAAP 3689
@@ -386,7 +387,7 @@ static gint ett_daap_sub = -1;
static expert_field ei_daap_max_recursion_depth_reached = EI_INIT;
/* Forward declarations */
-static void dissect_daap_one_tag(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, int recursion_depth);
+static void dissect_daap_one_tag(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb);
static int
dissect_daap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
@@ -419,26 +420,29 @@ dissect_daap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
ti = proto_tree_add_item(tree, proto_daap, tvb, 0, -1, ENC_NA);
daap_tree = proto_item_add_subtree(ti, ett_daap);
- dissect_daap_one_tag(daap_tree, pinfo, tvb, 0);
+ dissect_daap_one_tag(daap_tree, pinfo, tvb);
return tvb_captured_length(tvb);
}
#define DAAP_MAX_RECURSION_DEPTH 100
static void
-dissect_daap_one_tag(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, int recursion_depth)
+dissect_daap_one_tag(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb)
{
guint offset = 0;
guint32 tagname, tagsize;
proto_item *tag_ti;
proto_tree *tag_tree;
tvbuff_t *new_tvb;
+ unsigned recursion_depth = p_get_proto_depth(pinfo, proto_daap);
- if (recursion_depth >= DAAP_MAX_RECURSION_DEPTH) {
+ if (++recursion_depth >= DAAP_MAX_RECURSION_DEPTH) {
proto_tree_add_expert(tree, pinfo, &ei_daap_max_recursion_depth_reached,
tvb, 0, 0);
return;
}
+ p_set_proto_depth(pinfo, proto_daap, recursion_depth);
+
while (offset < tvb_reported_length(tvb)) {
tagname = tvb_get_ntohl(tvb, offset);
tagsize = tvb_get_ntohl(tvb, offset+4);
@@ -489,7 +493,7 @@ dissect_daap_one_tag(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, int re
case dacp_cmst:
/* Container tags */
new_tvb = tvb_new_subset_length(tvb, offset, (gint)tagsize);
- dissect_daap_one_tag(tag_tree, pinfo, new_tvb, recursion_depth+1);
+ dissect_daap_one_tag(tag_tree, pinfo, new_tvb);
break;
case daap_minm: