diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-26 17:44:18 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-26 17:44:18 +0000 |
commit | 1da76b3706a6c9bd41bf8f219d7c97de5e1e5c7f (patch) | |
tree | 9930fb4bb87cd6037f60efff9656f967121c8c2d /epan/dissectors/packet-bencode.c | |
parent | Adding debian version 4.2.2-1.1. (diff) | |
download | wireshark-1da76b3706a6c9bd41bf8f219d7c97de5e1e5c7f.tar.xz wireshark-1da76b3706a6c9bd41bf8f219d7c97de5e1e5c7f.zip |
Merging upstream version 4.2.4.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'epan/dissectors/packet-bencode.c')
-rw-r--r-- | epan/dissectors/packet-bencode.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/epan/dissectors/packet-bencode.c b/epan/dissectors/packet-bencode.c index 1f893e4c..93c042c3 100644 --- a/epan/dissectors/packet-bencode.c +++ b/epan/dissectors/packet-bencode.c @@ -163,6 +163,7 @@ static int dissect_bencoding_int(tvbuff_t *tvb, packet_info *pinfo, return -1; } +// NOLINTNEXTLINE(misc-no-recursion) static int dissect_bencoding_rec(tvbuff_t *tvb, packet_info *pinfo, int offset, int length, proto_tree *tree, int level, proto_item *treei, int treeadd) { @@ -207,8 +208,12 @@ static int dissect_bencoding_rec(tvbuff_t *tvb, packet_info *pinfo, } op2len = -1; - if ((length - op1len) > 2) + if ((length - op1len) > 2) { + increment_dissection_depth(pinfo); op2len = dissect_bencoding_rec(tvb, pinfo, offset + used + op1len, length - op1len, NULL, level + 1, NULL, 0); + decrement_dissection_depth(pinfo); + } + if (op2len < 0) { proto_tree_add_expert(dtree, pinfo, &ei_bencode_dict_value, tvb, offset + used + op1len, -1); return op2len; @@ -218,7 +223,9 @@ static int dissect_bencoding_rec(tvbuff_t *tvb, packet_info *pinfo, itree = proto_item_add_subtree(ti, ett_bencode_dict_entry); dissect_bencoding_str(tvb, pinfo, offset + used, length, itree, ti, 1); + increment_dissection_depth(pinfo); dissect_bencoding_rec(tvb, pinfo, offset + used + op1len, length - op1len, itree, level + 1, ti, 2); + decrement_dissection_depth(pinfo); used += op1len + op2len; length -= op1len + op2len; @@ -234,6 +241,7 @@ static int dissect_bencoding_rec(tvbuff_t *tvb, packet_info *pinfo, used = 1; length--; + increment_dissection_depth(pinfo); while (length >= 1) { op = tvb_get_guint8(tvb, offset + used); @@ -242,11 +250,16 @@ static int dissect_bencoding_rec(tvbuff_t *tvb, packet_info *pinfo, } oplen = dissect_bencoding_rec(tvb, pinfo, offset + used, length, itree, level + 1, ti, 0); - if (oplen < 1) return oplen; + + if (oplen < 1) { + decrement_dissection_depth(pinfo); + return oplen; + } used += oplen; length -= oplen; } + decrement_dissection_depth(pinfo); proto_tree_add_item(itree, hf_bencode_truncated_data, tvb, offset + used, -1, ENC_NA); return -1; |