aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2023-12-31 15:06:40 -0800
committerGerald Combs <gerald@wireshark.org>2024-01-02 09:23:40 -0800
commit8f797db63ca44875a07d0d8a5d298a79d09b44ec (patch)
treecf5c4545b4f78f4c11aa01a5a6309d8f7aca2ff9 /epan
parentc9c40514d866e8e9b16e72b5233158ba134bf044 (diff)
asn2wrs: Add recursion checks
Add a recursion depth check whenever we have cyclic dependencies. Regenerate our dissectors. Fixes #19501
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/asn1/cmip/packet-cmip-template.c1
-rw-r--r--epan/dissectors/asn1/cmp/packet-cmp-template.c1
-rw-r--r--epan/dissectors/asn1/dap/packet-dap-template.c1
-rw-r--r--epan/dissectors/asn1/disp/packet-disp-template.c1
-rw-r--r--epan/dissectors/asn1/glow/packet-glow-template.c1
-rw-r--r--epan/dissectors/asn1/goose/packet-goose-template.c1
-rw-r--r--epan/dissectors/asn1/h245/packet-h245-template.c1
-rw-r--r--epan/dissectors/asn1/h248/packet-h248-template.c1
-rw-r--r--epan/dissectors/asn1/ldap/packet-ldap-template.c1
-rw-r--r--epan/dissectors/asn1/p22/packet-p22-template.c1
-rw-r--r--epan/dissectors/asn1/p7/packet-p7-template.c1
-rw-r--r--epan/dissectors/asn1/x509if/packet-x509if-template.c1
-rw-r--r--epan/dissectors/asn1/x509sat/packet-x509sat-template.c1
-rw-r--r--epan/dissectors/packet-cmip.c8
-rw-r--r--epan/dissectors/packet-cmp.c8
-rw-r--r--epan/dissectors/packet-dap.c26
-rw-r--r--epan/dissectors/packet-disp.c14
-rw-r--r--epan/dissectors/packet-e2ap.c19
-rw-r--r--epan/dissectors/packet-glow.c20
-rw-r--r--epan/dissectors/packet-goose.c8
-rw-r--r--epan/dissectors/packet-h225.c13
-rw-r--r--epan/dissectors/packet-h245.c44
-rw-r--r--epan/dissectors/packet-h248.c8
-rw-r--r--epan/dissectors/packet-ieee1609dot2.c7
-rw-r--r--epan/dissectors/packet-its.c7
-rw-r--r--epan/dissectors/packet-ldap.c8
-rw-r--r--epan/dissectors/packet-mms.c25
-rw-r--r--epan/dissectors/packet-p22.c26
-rw-r--r--epan/dissectors/packet-p7.c8
-rw-r--r--epan/dissectors/packet-x509if.c20
-rw-r--r--epan/dissectors/packet-x509sat.c8
-rw-r--r--epan/dissectors/packet-z3950.c19
32 files changed, 309 insertions, 0 deletions
diff --git a/epan/dissectors/asn1/cmip/packet-cmip-template.c b/epan/dissectors/asn1/cmip/packet-cmip-template.c
index ec2dee8547..4e7a249493 100644
--- a/epan/dissectors/asn1/cmip/packet-cmip-template.c
+++ b/epan/dissectors/asn1/cmip/packet-cmip-template.c
@@ -15,6 +15,7 @@
#include <epan/expert.h>
#include <epan/oids.h>
#include <epan/asn1.h>
+#include <epan/proto_data.h>
#include "packet-ber.h"
#include "packet-acse.h"
diff --git a/epan/dissectors/asn1/cmp/packet-cmp-template.c b/epan/dissectors/asn1/cmp/packet-cmp-template.c
index c57bd6eb88..c6af656260 100644
--- a/epan/dissectors/asn1/cmp/packet-cmp-template.c
+++ b/epan/dissectors/asn1/cmp/packet-cmp-template.c
@@ -18,6 +18,7 @@
#include <epan/oids.h>
#include <epan/asn1.h>
+#include <epan/proto_data.h>
#include "packet-ber.h"
#include "packet-cmp.h"
#include "packet-crmf.h"
diff --git a/epan/dissectors/asn1/dap/packet-dap-template.c b/epan/dissectors/asn1/dap/packet-dap-template.c
index 359ed0cebf..faea88614c 100644
--- a/epan/dissectors/asn1/dap/packet-dap-template.c
+++ b/epan/dissectors/asn1/dap/packet-dap-template.c
@@ -16,6 +16,7 @@
#include <epan/expert.h>
#include <epan/oids.h>
#include <epan/asn1.h>
+#include <epan/proto_data.h>
#include "packet-ber.h"
#include "packet-acse.h"
diff --git a/epan/dissectors/asn1/disp/packet-disp-template.c b/epan/dissectors/asn1/disp/packet-disp-template.c
index 156d5e8c42..6b8091a897 100644
--- a/epan/dissectors/asn1/disp/packet-disp-template.c
+++ b/epan/dissectors/asn1/disp/packet-disp-template.c
@@ -16,6 +16,7 @@
#include <epan/prefs.h>
#include <epan/oids.h>
#include <epan/asn1.h>
+#include <epan/proto_data.h>
#include "packet-ber.h"
#include "packet-acse.h"
diff --git a/epan/dissectors/asn1/glow/packet-glow-template.c b/epan/dissectors/asn1/glow/packet-glow-template.c
index fea6429d40..0f39fbc8e9 100644
--- a/epan/dissectors/asn1/glow/packet-glow-template.c
+++ b/epan/dissectors/asn1/glow/packet-glow-template.c
@@ -13,6 +13,7 @@
# include "config.h"
#include <epan/packet.h>
+#include <epan/proto_data.h>
#include "packet-ber.h"
#define PNAME "Glow"
diff --git a/epan/dissectors/asn1/goose/packet-goose-template.c b/epan/dissectors/asn1/goose/packet-goose-template.c
index e034e88a51..fccf311938 100644
--- a/epan/dissectors/asn1/goose/packet-goose-template.c
+++ b/epan/dissectors/asn1/goose/packet-goose-template.c
@@ -16,6 +16,7 @@
#include <epan/packet.h>
#include <epan/asn1.h>
+#include <epan/proto_data.h>
#include <epan/etypes.h>
#include <epan/expert.h>
diff --git a/epan/dissectors/asn1/h245/packet-h245-template.c b/epan/dissectors/asn1/h245/packet-h245-template.c
index e03a06087c..c1b05c4e5d 100644
--- a/epan/dissectors/asn1/h245/packet-h245-template.c
+++ b/epan/dissectors/asn1/h245/packet-h245-template.c
@@ -28,6 +28,7 @@
#include <epan/t35.h>
#include <epan/oids.h>
#include <epan/asn1.h>
+#include <epan/proto_data.h>
#include <epan/tap.h>
#include <wsutil/pint.h>
#include "packet-tpkt.h"
diff --git a/epan/dissectors/asn1/h248/packet-h248-template.c b/epan/dissectors/asn1/h248/packet-h248-template.c
index 0785bc6a7b..54a40d08e7 100644
--- a/epan/dissectors/asn1/h248/packet-h248-template.c
+++ b/epan/dissectors/asn1/h248/packet-h248-template.c
@@ -18,6 +18,7 @@
#include <epan/exceptions.h>
#include <epan/tap.h>
#include <epan/asn1.h>
+#include <epan/proto_data.h>
#include <epan/prefs.h>
#include <epan/exported_pdu.h>
#include <epan/address_types.h>
diff --git a/epan/dissectors/asn1/ldap/packet-ldap-template.c b/epan/dissectors/asn1/ldap/packet-ldap-template.c
index ce4dc323d8..13cd006992 100644
--- a/epan/dissectors/asn1/ldap/packet-ldap-template.c
+++ b/epan/dissectors/asn1/ldap/packet-ldap-template.c
@@ -80,6 +80,7 @@
#include <epan/strutil.h>
#include <epan/show_exception.h>
#include <epan/asn1.h>
+#include <epan/proto_data.h>
#include <epan/expert.h>
#include <epan/uat.h>
#include <epan/charsets.h>
diff --git a/epan/dissectors/asn1/p22/packet-p22-template.c b/epan/dissectors/asn1/p22/packet-p22-template.c
index af886f7186..33ecfc274b 100644
--- a/epan/dissectors/asn1/p22/packet-p22-template.c
+++ b/epan/dissectors/asn1/p22/packet-p22-template.c
@@ -14,6 +14,7 @@
#include <epan/packet.h>
#include <epan/oids.h>
#include <epan/asn1.h>
+#include <epan/proto_data.h>
#include "packet-ber.h"
#include "packet-acse.h"
diff --git a/epan/dissectors/asn1/p7/packet-p7-template.c b/epan/dissectors/asn1/p7/packet-p7-template.c
index 8f703e364d..04851e18f9 100644
--- a/epan/dissectors/asn1/p7/packet-p7-template.c
+++ b/epan/dissectors/asn1/p7/packet-p7-template.c
@@ -15,6 +15,7 @@
#include <epan/prefs.h>
#include <epan/oids.h>
#include <epan/asn1.h>
+#include <epan/proto_data.h>
#include "packet-ber.h"
#include "packet-acse.h"
diff --git a/epan/dissectors/asn1/x509if/packet-x509if-template.c b/epan/dissectors/asn1/x509if/packet-x509if-template.c
index a7afacd796..0b4a20e8c5 100644
--- a/epan/dissectors/asn1/x509if/packet-x509if-template.c
+++ b/epan/dissectors/asn1/x509if/packet-x509if-template.c
@@ -14,6 +14,7 @@
#include <epan/packet.h>
#include <epan/oids.h>
#include <epan/asn1.h>
+#include <epan/proto_data.h>
#include <epan/strutil.h>
#include "packet-ber.h"
diff --git a/epan/dissectors/asn1/x509sat/packet-x509sat-template.c b/epan/dissectors/asn1/x509sat/packet-x509sat-template.c
index ec5d40f785..7f69da40ef 100644
--- a/epan/dissectors/asn1/x509sat/packet-x509sat-template.c
+++ b/epan/dissectors/asn1/x509sat/packet-x509sat-template.c
@@ -14,6 +14,7 @@
#include <epan/packet.h>
#include <epan/oids.h>
#include <epan/asn1.h>
+#include <epan/proto_data.h>
#include <epan/strutil.h>
#include "packet-ber.h"
diff --git a/epan/dissectors/packet-cmip.c b/epan/dissectors/packet-cmip.c
index 0d745dca96..8bee65f341 100644
--- a/epan/dissectors/packet-cmip.c
+++ b/epan/dissectors/packet-cmip.c
@@ -20,6 +20,7 @@
#include <epan/expert.h>
#include <epan/oids.h>
#include <epan/asn1.h>
+#include <epan/proto_data.h>
#include "packet-ber.h"
#include "packet-acse.h"
@@ -601,6 +602,7 @@ static const char *object_identifier_id;
static int dissect_cmip_CMISFilter(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_);
+#define MAX_RECURSION_DEPTH 100 // Arbitrarily chosen.
static int
@@ -1010,10 +1012,16 @@ static const ber_choice_t CMISFilter_choice[] = {
static int
dissect_cmip_CMISFilter(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 3;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
offset = dissect_ber_choice(actx, tree, tvb, offset,
CMISFilter_choice, hf_index, ett_cmip_CMISFilter,
NULL);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
diff --git a/epan/dissectors/packet-cmp.c b/epan/dissectors/packet-cmp.c
index 2ea2f734d1..9df3193b43 100644
--- a/epan/dissectors/packet-cmp.c
+++ b/epan/dissectors/packet-cmp.c
@@ -23,6 +23,7 @@
#include <epan/oids.h>
#include <epan/asn1.h>
+#include <epan/proto_data.h>
#include "packet-ber.h"
#include "packet-cmp.h"
#include "packet-crmf.h"
@@ -276,6 +277,7 @@ static gint ett_cmp_PollRepContent_item;
/*int dissect_cmp_PKIMessage(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_);*/
+#define MAX_RECURSION_DEPTH 100 // Arbitrarily chosen.
static const value_string cmp_CMPCertificate_vals[] = {
{ 0, "x509v3PKCert" },
@@ -1086,9 +1088,15 @@ static const ber_sequence_t PKIMessage_sequence[] = {
int
dissect_cmp_PKIMessage(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 5;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
PKIMessage_sequence, hf_index, ett_cmp_PKIMessage);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
diff --git a/epan/dissectors/packet-dap.c b/epan/dissectors/packet-dap.c
index 0b12cc0722..3da59b53fa 100644
--- a/epan/dissectors/packet-dap.c
+++ b/epan/dissectors/packet-dap.c
@@ -21,6 +21,7 @@
#include <epan/expert.h>
#include <epan/oids.h>
#include <epan/asn1.h>
+#include <epan/proto_data.h>
#include "packet-ber.h"
#include "packet-acse.h"
@@ -700,6 +701,7 @@ static int dissect_dap_ListResultData(bool implicit_tag _U_, tvbuff_t *tvb _U_,
static int dissect_dap_SearchResultData(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_);
+#define MAX_RECURSION_DEPTH 100 // Arbitrarily chosen.
const value_string dap_FamilyGrouping_vals[] = {
{ 1, "entryOnly" },
@@ -1264,9 +1266,15 @@ static const ber_sequence_t FamilyEntries_sequence[] = {
static int
dissect_dap_FamilyEntries(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 5;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
FamilyEntries_sequence, hf_index, ett_dap_FamilyEntries);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
@@ -1462,10 +1470,16 @@ static const ber_choice_t Filter_choice[] = {
int
dissect_dap_Filter(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 3;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
offset = dissect_ber_choice(actx, tree, tvb, offset,
Filter_choice, hf_index, ett_dap_Filter,
NULL);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
@@ -2918,10 +2932,16 @@ static const ber_choice_t ListResultData_choice[] = {
static int
dissect_dap_ListResultData(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 4;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
offset = dissect_ber_choice(actx, tree, tvb, offset,
ListResultData_choice, hf_index, ett_dap_ListResultData,
NULL);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
@@ -3303,10 +3323,16 @@ static const ber_choice_t SearchResultData_choice[] = {
static int
dissect_dap_SearchResultData(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 4;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
offset = dissect_ber_choice(actx, tree, tvb, offset,
SearchResultData_choice, hf_index, ett_dap_SearchResultData,
NULL);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
diff --git a/epan/dissectors/packet-disp.c b/epan/dissectors/packet-disp.c
index 88e1467fc7..e5326a9df9 100644
--- a/epan/dissectors/packet-disp.c
+++ b/epan/dissectors/packet-disp.c
@@ -21,6 +21,7 @@
#include <epan/prefs.h>
#include <epan/oids.h>
#include <epan/asn1.h>
+#include <epan/proto_data.h>
#include "packet-ber.h"
#include "packet-acse.h"
@@ -231,6 +232,7 @@ static int dissect_disp_Subtree(bool implicit_tag _U_, tvbuff_t *tvb _U_, int of
static int dissect_disp_IncrementalStepRefresh(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_);
+#define MAX_RECURSION_DEPTH 100 // Arbitrarily chosen.
static int
@@ -1040,9 +1042,15 @@ static const ber_sequence_t Subtree_sequence[] = {
static int
dissect_disp_Subtree(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 3;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
Subtree_sequence, hf_index, ett_disp_Subtree);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
@@ -1198,9 +1206,15 @@ static const ber_sequence_t IncrementalStepRefresh_sequence[] = {
static int
dissect_disp_IncrementalStepRefresh(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 4;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
IncrementalStepRefresh_sequence, hf_index, ett_disp_IncrementalStepRefresh);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
diff --git a/epan/dissectors/packet-e2ap.c b/epan/dissectors/packet-e2ap.c
index 635e32b531..0cb33744cb 100644
--- a/epan/dissectors/packet-e2ap.c
+++ b/epan/dissectors/packet-e2ap.c
@@ -2190,6 +2190,7 @@ static int dissect_e2ap_RANParameter_Definition(tvbuff_t *tvb _U_, int offset _U
static int dissect_e2ap_RANParameter_ValueType(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_);
+#define MAX_RECURSION_DEPTH 100 // Arbitrarily chosen.
static const value_string e2ap_Criticality_vals[] = {
{ 0, "reject" },
@@ -7418,9 +7419,15 @@ static const per_sequence_t RANParameter_Testing_Item_sequence[] = {
static int
dissect_e2ap_RANParameter_Testing_Item(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 5;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_e2ap_RANParameter_Testing_Item, RANParameter_Testing_Item_sequence);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
@@ -7805,9 +7812,15 @@ static const per_sequence_t RANParameter_Definition_sequence[] = {
static int
dissect_e2ap_RANParameter_Definition(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 6;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_e2ap_RANParameter_Definition, RANParameter_Definition_sequence);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
@@ -7957,10 +7970,16 @@ static const per_choice_t RANParameter_ValueType_choice[] = {
static int
dissect_e2ap_RANParameter_ValueType(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 6;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
offset = dissect_per_choice(tvb, offset, actx, tree, hf_index,
ett_e2ap_RANParameter_ValueType, RANParameter_ValueType_choice,
NULL);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
diff --git a/epan/dissectors/packet-glow.c b/epan/dissectors/packet-glow.c
index fca30d1ff2..a924eab7cd 100644
--- a/epan/dissectors/packet-glow.c
+++ b/epan/dissectors/packet-glow.c
@@ -18,6 +18,7 @@
# include "config.h"
#include <epan/packet.h>
+#include <epan/proto_data.h>
#include "packet-ber.h"
#define PNAME "Glow"
@@ -184,6 +185,7 @@ static int dissect_glow_ElementCollection(bool implicit_tag _U_, tvbuff_t *tvb _
static int dissect_glow_Template(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_);
+#define MAX_RECURSION_DEPTH 100 // Arbitrarily chosen.
static int
@@ -1084,9 +1086,15 @@ dissect_glow_SEQUENCE_OF_Element(bool implicit_tag _U_, tvbuff_t *tvb _U_, int o
static int
dissect_glow_ElementCollection(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 6;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
hf_index, BER_CLASS_APP, 4, TRUE, dissect_glow_SEQUENCE_OF_Element);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
@@ -1110,9 +1118,15 @@ dissect_glow_Parameter_U(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U
static int
dissect_glow_Parameter(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 6;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
hf_index, BER_CLASS_APP, 1, TRUE, dissect_glow_Parameter_U);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
@@ -1162,9 +1176,15 @@ dissect_glow_Template_U(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_
static int
dissect_glow_Template(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 9;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
hf_index, BER_CLASS_APP, 24, TRUE, dissect_glow_Template_U);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
diff --git a/epan/dissectors/packet-goose.c b/epan/dissectors/packet-goose.c
index 34eae5f128..1a8d5ac9b3 100644
--- a/epan/dissectors/packet-goose.c
+++ b/epan/dissectors/packet-goose.c
@@ -21,6 +21,7 @@
#include <epan/packet.h>
#include <epan/asn1.h>
+#include <epan/proto_data.h>
#include <epan/etypes.h>
#include <epan/expert.h>
@@ -186,6 +187,7 @@ static gint ett_goose_Data;
static int dissect_goose_Data(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_);
+#define MAX_RECURSION_DEPTH 100 // Arbitrarily chosen.
static int
@@ -709,10 +711,16 @@ static const ber_choice_t Data_choice[] = {
static int
dissect_goose_Data(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 3;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
offset = dissect_ber_choice(actx, tree, tvb, offset,
Data_choice, hf_index, ett_goose_Data,
NULL);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
diff --git a/epan/dissectors/packet-h225.c b/epan/dissectors/packet-h225.c
index 2866363e98..3d77297d73 100644
--- a/epan/dissectors/packet-h225.c
+++ b/epan/dissectors/packet-h225.c
@@ -1257,6 +1257,7 @@ static int dissect_h225_EnumeratedParameter(tvbuff_t *tvb _U_, int offset _U_, a
/*int dissect_h225_GenericData(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_);*/
+#define MAX_RECURSION_DEPTH 100 // Arbitrarily chosen.
static int
@@ -3967,6 +3968,11 @@ static const per_sequence_t EnumeratedParameter_sequence[] = {
static int
dissect_h225_EnumeratedParameter(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 4;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
gef_ctx_t *parent_gefx;
parent_gefx = gef_ctx_get(actx->private_data);
@@ -3974,6 +3980,7 @@ dissect_h225_EnumeratedParameter(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_h225_EnumeratedParameter, EnumeratedParameter_sequence);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
actx->private_data = parent_gefx;
return offset;
}
@@ -3987,6 +3994,11 @@ static const per_sequence_t GenericData_sequence[] = {
int
dissect_h225_GenericData(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 6;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
void *priv_data = actx->private_data;
gef_ctx_t *gefx;
@@ -3999,6 +4011,7 @@ dissect_h225_GenericData(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_h225_GenericData, GenericData_sequence);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
actx->private_data = priv_data;
return offset;
}
diff --git a/epan/dissectors/packet-h245.c b/epan/dissectors/packet-h245.c
index b353def3b2..2334ab99d1 100644
--- a/epan/dissectors/packet-h245.c
+++ b/epan/dissectors/packet-h245.c
@@ -33,6 +33,7 @@
#include <epan/t35.h>
#include <epan/oids.h>
#include <epan/asn1.h>
+#include <epan/proto_data.h>
#include <epan/tap.h>
#include <wsutil/pint.h>
#include "packet-tpkt.h"
@@ -2425,6 +2426,7 @@ static int dissect_h245_AudioMode(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t
static int dissect_h245_ModeElementType(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_);
+#define MAX_RECURSION_DEPTH 100 // Arbitrarily chosen.
static int
@@ -3863,9 +3865,15 @@ static const per_sequence_t GenericParameter_sequence[] = {
static int
dissect_h245_GenericParameter(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 4;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_h245_GenericParameter, GenericParameter_sequence);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
@@ -5658,6 +5666,11 @@ static const per_choice_t VideoCapability_choice[] = {
static int
dissect_h245_VideoCapability(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 4;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
gint32 value;
offset = dissect_per_choice(tvb, offset, actx, tree, hf_index,
@@ -5667,6 +5680,7 @@ dissect_h245_VideoCapability(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx
codec_type = val_to_str(value, h245_VideoCapability_vals, "<unknown>");
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
@@ -5974,6 +5988,11 @@ static const per_choice_t AudioCapability_choice[] = {
static int
dissect_h245_AudioCapability(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 3;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
gint32 value;
offset = dissect_per_choice(tvb, offset, actx, tree, hf_index,
@@ -5982,6 +6001,7 @@ dissect_h245_AudioCapability(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx
codec_type = val_to_str(value, h245_AudioCapability_short_vals, "<unknown>");
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
@@ -7132,6 +7152,11 @@ static const per_choice_t DataType_choice[] = {
static int
dissect_h245_DataType(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 5;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
gint choice_index;
offset = dissect_per_choice(tvb, offset, actx, tree, hf_index,
@@ -7148,6 +7173,7 @@ if (upcoming_channel){
}
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
@@ -8848,6 +8874,11 @@ static const per_sequence_t MultiplexElement_sequence[] = {
static int
dissect_h245_MultiplexElement(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 4;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
/*MultiplexElement*/
h223_mux_element* me = wmem_new(wmem_file_scope(), h223_mux_element);
h223_me->next = me;
@@ -8856,6 +8887,7 @@ dissect_h245_MultiplexElement(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *act
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_h245_MultiplexElement, MultiplexElement_sequence);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
@@ -9477,6 +9509,11 @@ static const per_choice_t AudioMode_choice[] = {
static int
dissect_h245_AudioMode(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 3;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
gint32 value;
offset = dissect_per_choice(tvb, offset, actx, tree, hf_index,
@@ -9485,6 +9522,7 @@ dissect_h245_AudioMode(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_,
codec_type = val_to_str(value, h245_AudioMode_vals, "<unknown>");
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
@@ -9830,10 +9868,16 @@ static const per_choice_t ModeElementType_choice[] = {
static int
dissect_h245_ModeElementType(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 6;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
offset = dissect_per_choice(tvb, offset, actx, tree, hf_index,
ett_h245_ModeElementType, ModeElementType_choice,
NULL);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
diff --git a/epan/dissectors/packet-h248.c b/epan/dissectors/packet-h248.c
index 955525688c..3f1e6f3a8c 100644
--- a/epan/dissectors/packet-h248.c
+++ b/epan/dissectors/packet-h248.c
@@ -23,6 +23,7 @@
#include <epan/exceptions.h>
#include <epan/tap.h>
#include <epan/asn1.h>
+#include <epan/proto_data.h>
#include <epan/prefs.h>
#include <epan/exported_pdu.h>
#include <epan/address_types.h>
@@ -2618,6 +2619,7 @@ static int dissect_h248_MtpAddress(bool implicit_tag, tvbuff_t *tvb, int offset,
static int dissect_h248_SecondEventsDescriptor(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_);
+#define MAX_RECURSION_DEPTH 100 // Arbitrarily chosen.
static int
@@ -4246,9 +4248,15 @@ static const ber_sequence_t SecondEventsDescriptor_sequence[] = {
static int
dissect_h248_SecondEventsDescriptor(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 7;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
SecondEventsDescriptor_sequence, hf_index, ett_h248_SecondEventsDescriptor);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
diff --git a/epan/dissectors/packet-ieee1609dot2.c b/epan/dissectors/packet-ieee1609dot2.c
index 8ef20371e0..3de7da808c 100644
--- a/epan/dissectors/packet-ieee1609dot2.c
+++ b/epan/dissectors/packet-ieee1609dot2.c
@@ -427,6 +427,7 @@ ieee1609dot2_set_next_default_psid(packet_info *pinfo, guint32 psid)
static int dissect_ieee1609dot2_Ieee1609Dot2Data(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_);
+#define MAX_RECURSION_DEPTH 100 // Arbitrarily chosen.
static int
@@ -3023,10 +3024,16 @@ static const oer_sequence_t Ieee1609Dot2Data_sequence[] = {
static int
dissect_ieee1609dot2_Ieee1609Dot2Data(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 6;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
actx->private_data = (void*)wmem_new0(actx->pinfo->pool, ieee1609_private_data_t);
offset = dissect_oer_sequence(tvb, offset, actx, tree, hf_index,
ett_ieee1609dot2_Ieee1609Dot2Data, Ieee1609Dot2Data_sequence);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
diff --git a/epan/dissectors/packet-its.c b/epan/dissectors/packet-its.c
index 3174ff1447..9efb8055ca 100644
--- a/epan/dissectors/packet-its.c
+++ b/epan/dissectors/packet-its.c
@@ -14082,6 +14082,7 @@ static int dissect_AddGrpC_SignalStatusPackage_addGrpC_PDU(tvbuff_t *tvb _U_, pa
static int dissect_gdd_GddStructure(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_);
+#define MAX_RECURSION_DEPTH 100 // Arbitrarily chosen.
static int
@@ -14998,9 +14999,15 @@ static const per_sequence_t gdd_GddStructure_sequence[] = {
static int
dissect_gdd_GddStructure(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 9;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_gdd_GddStructure, gdd_GddStructure_sequence);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
diff --git a/epan/dissectors/packet-ldap.c b/epan/dissectors/packet-ldap.c
index 0856ab7def..9215d9b61f 100644
--- a/epan/dissectors/packet-ldap.c
+++ b/epan/dissectors/packet-ldap.c
@@ -85,6 +85,7 @@
#include <epan/strutil.h>
#include <epan/show_exception.h>
#include <epan/asn1.h>
+#include <epan/proto_data.h>
#include <epan/expert.h>
#include <epan/uat.h>
#include <epan/charsets.h>
@@ -1114,6 +1115,7 @@ ldap_match_call_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gu
static int dissect_ldap_Filter(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_);
+#define MAX_RECURSION_DEPTH 100 // Arbitrarily chosen.
static int
@@ -2172,6 +2174,11 @@ static const ber_choice_t Filter_choice[] = {
static int
dissect_ldap_Filter(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 4;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
proto_tree *tr;
proto_item *it;
attributedesc_string=NULL;
@@ -2197,6 +2204,7 @@ dissect_ldap_Filter(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, as
proto_item_append_text(it, "%s", string_or_null(Filter_string));
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
diff --git a/epan/dissectors/packet-mms.c b/epan/dissectors/packet-mms.c
index 767fff9929..9464d1cd58 100644
--- a/epan/dissectors/packet-mms.c
+++ b/epan/dissectors/packet-mms.c
@@ -1039,6 +1039,7 @@ static int dissect_mms_AlternateAccess(bool implicit_tag _U_, tvbuff_t *tvb _U_,
static int dissect_mms_Data(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_);
+#define MAX_RECURSION_DEPTH 100 // Arbitrarily chosen.
static int
@@ -1557,10 +1558,16 @@ static const ber_choice_t TypeSpecification_choice[] = {
static int
dissect_mms_TypeSpecification(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 3;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
offset = dissect_ber_choice(actx, tree, tvb, offset,
TypeSpecification_choice, hf_index, ett_mms_TypeSpecification,
NULL);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
@@ -1742,9 +1749,15 @@ static const ber_sequence_t AlternateAccess_sequence_of[1] = {
static int
dissect_mms_AlternateAccess(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 5;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
AlternateAccess_sequence_of, hf_index, ett_mms_AlternateAccess);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
@@ -1798,10 +1811,16 @@ static const ber_choice_t VariableSpecification_choice[] = {
static int
dissect_mms_VariableSpecification(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 4;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
offset = dissect_ber_choice(actx, tree, tvb, offset,
VariableSpecification_choice, hf_index, ett_mms_VariableSpecification,
NULL);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
@@ -2078,10 +2097,16 @@ static const ber_choice_t Data_choice[] = {
static int
dissect_mms_Data(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 3;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
offset = dissect_ber_choice(actx, tree, tvb, offset,
Data_choice, hf_index, ett_mms_Data,
NULL);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
diff --git a/epan/dissectors/packet-p22.c b/epan/dissectors/packet-p22.c
index 6e5b2b08d4..9726274ddd 100644
--- a/epan/dissectors/packet-p22.c
+++ b/epan/dissectors/packet-p22.c
@@ -19,6 +19,7 @@
#include <epan/packet.h>
#include <epan/oids.h>
#include <epan/asn1.h>
+#include <epan/proto_data.h>
#include "packet-ber.h"
#include "packet-acse.h"
@@ -838,6 +839,7 @@ static int dissect_p22_BodyPartTokens(bool implicit_tag _U_, tvbuff_t *tvb _U_,
static int dissect_p22_ForwardedContentToken(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_);
+#define MAX_RECURSION_DEPTH 100 // Arbitrarily chosen.
static int
@@ -1800,6 +1802,11 @@ static const ber_sequence_t IPM_sequence[] = {
int
dissect_p22_IPM(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 7;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
col_append_str(actx->pinfo->cinfo, COL_INFO, " Message");
@@ -1809,6 +1816,7 @@ dissect_p22_IPM(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_c
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
@@ -3511,9 +3519,15 @@ static const ber_sequence_t IPMSynopsis_sequence_of[1] = {
static int
dissect_p22_IPMSynopsis(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 4;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
IPMSynopsis_sequence_of, hf_index, ett_p22_IPMSynopsis);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
@@ -3971,9 +3985,15 @@ static const ber_sequence_t BodyPartTokens_set_of[1] = {
static int
dissect_p22_BodyPartTokens(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 4;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
offset = dissect_ber_set_of(implicit_tag, actx, tree, tvb, offset,
BodyPartTokens_set_of, hf_index, ett_p22_BodyPartTokens);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
@@ -4021,9 +4041,15 @@ static const ber_sequence_t ForwardedContentToken_set_of[1] = {
static int
dissect_p22_ForwardedContentToken(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 4;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
offset = dissect_ber_set_of(implicit_tag, actx, tree, tvb, offset,
ForwardedContentToken_set_of, hf_index, ett_p22_ForwardedContentToken);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
diff --git a/epan/dissectors/packet-p7.c b/epan/dissectors/packet-p7.c
index d005fc3315..31126a4b6e 100644
--- a/epan/dissectors/packet-p7.c
+++ b/epan/dissectors/packet-p7.c
@@ -20,6 +20,7 @@
#include <epan/prefs.h>
#include <epan/oids.h>
#include <epan/asn1.h>
+#include <epan/proto_data.h>
#include "packet-ber.h"
#include "packet-acse.h"
@@ -643,6 +644,7 @@ static const value_string p7_err_code_string_vals[] = {
static int dissect_p7_Filter(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_);
+#define MAX_RECURSION_DEPTH 100 // Arbitrarily chosen.
static int
@@ -1557,10 +1559,16 @@ static const ber_choice_t Filter_choice[] = {
static int
dissect_p7_Filter(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 3;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
offset = dissect_ber_choice(actx, tree, tvb, offset,
Filter_choice, hf_index, ett_p7_Filter,
NULL);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
diff --git a/epan/dissectors/packet-x509if.c b/epan/dissectors/packet-x509if.c
index 36ac843f0d..8025d83671 100644
--- a/epan/dissectors/packet-x509if.c
+++ b/epan/dissectors/packet-x509if.c
@@ -19,6 +19,7 @@
#include <epan/packet.h>
#include <epan/oids.h>
#include <epan/asn1.h>
+#include <epan/proto_data.h>
#include <epan/strutil.h>
#include "packet-ber.h"
@@ -315,6 +316,7 @@ x509if_frame_end(void)
/*int dissect_x509if_AttributeCombination(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_);*/
+#define MAX_RECURSION_DEPTH 100 // Arbitrarily chosen.
static int
@@ -1046,10 +1048,16 @@ static const ber_choice_t Refinement_choice[] = {
int
dissect_x509if_Refinement(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 3;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
offset = dissect_ber_choice(actx, tree, tvb, offset,
Refinement_choice, hf_index, ett_x509if_Refinement,
NULL);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
@@ -1485,10 +1493,16 @@ static const ber_choice_t ContextCombination_choice[] = {
int
dissect_x509if_ContextCombination(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 3;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
offset = dissect_ber_choice(actx, tree, tvb, offset,
ContextCombination_choice, hf_index, ett_x509if_ContextCombination,
NULL);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
@@ -1604,10 +1618,16 @@ static const ber_choice_t AttributeCombination_choice[] = {
int
dissect_x509if_AttributeCombination(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 3;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
offset = dissect_ber_choice(actx, tree, tvb, offset,
AttributeCombination_choice, hf_index, ett_x509if_AttributeCombination,
NULL);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
diff --git a/epan/dissectors/packet-x509sat.c b/epan/dissectors/packet-x509sat.c
index b691724b47..58ce5bba81 100644
--- a/epan/dissectors/packet-x509sat.c
+++ b/epan/dissectors/packet-x509sat.c
@@ -19,6 +19,7 @@
#include <epan/packet.h>
#include <epan/oids.h>
#include <epan/asn1.h>
+#include <epan/proto_data.h>
#include <epan/strutil.h>
#include "packet-ber.h"
@@ -257,6 +258,7 @@ static gint ett_x509sat_LocaleContextSyntax;
/*int dissect_x509sat_Criteria(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_);*/
+#define MAX_RECURSION_DEPTH 100 // Arbitrarily chosen.
static int
@@ -431,10 +433,16 @@ static const ber_choice_t Criteria_choice[] = {
int
dissect_x509sat_Criteria(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 3;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
offset = dissect_ber_choice(actx, tree, tvb, offset,
Criteria_choice, hf_index, ett_x509sat_Criteria,
NULL);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
diff --git a/epan/dissectors/packet-z3950.c b/epan/dissectors/packet-z3950.c
index aa93dc6e04..2d1d4eebb1 100644
--- a/epan/dissectors/packet-z3950.c
+++ b/epan/dissectors/packet-z3950.c
@@ -2070,6 +2070,7 @@ static int dissect_z3950_ElementInfo(bool implicit_tag _U_, tvbuff_t *tvb _U_, i
static int dissect_z3950_TaggedElement(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_);
+#define MAX_RECURSION_DEPTH 100 // Arbitrarily chosen.
static int
@@ -3031,10 +3032,16 @@ static const ber_choice_t RPNStructure_choice[] = {
static int
dissect_z3950_RPNStructure(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 3;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
offset = dissect_ber_choice(actx, tree, tvb, offset,
RPNStructure_choice, hf_index, ett_z3950_RPNStructure,
NULL);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
@@ -6536,9 +6543,15 @@ static const ber_sequence_t ElementInfo_sequence[] = {
static int
dissect_z3950_ElementInfo(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 4;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
ElementInfo_sequence, hf_index, ett_z3950_ElementInfo);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}
@@ -8011,9 +8024,15 @@ static const ber_sequence_t TaggedElement_sequence[] = {
static int
dissect_z3950_TaggedElement(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ const int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_tail(actx->pinfo->layers)));
+ const unsigned cycle_size = 4;
+ unsigned recursion_depth = p_get_proto_depth(actx->pinfo, proto_id);
+ DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth + cycle_size);
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
TaggedElement_sequence, hf_index, ett_z3950_TaggedElement);
+ p_set_proto_depth(actx->pinfo, proto_id, recursion_depth - cycle_size);
return offset;
}