diff options
author | Kevin Albertson <kevin.eric.albertson@gmail.com> | 2022-11-13 08:49:54 -0500 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2022-11-13 16:19:19 +0000 |
commit | 24d55ce7ac82c2a32171c0c229efe09169fd4fff (patch) | |
tree | 3e31ef7660b0530ce375acd8733d241d5d094995 /epan/dissectors/packet-mongo.c | |
parent | 2b43f5f650288ecb39497f7dad2f15888e83b120 (diff) |
move depth increment below error checks
Diffstat (limited to 'epan/dissectors/packet-mongo.c')
-rw-r--r-- | epan/dissectors/packet-mongo.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/epan/dissectors/packet-mongo.c b/epan/dissectors/packet-mongo.c index 91d2730f3a..c576e53796 100644 --- a/epan/dissectors/packet-mongo.c +++ b/epan/dissectors/packet-mongo.c @@ -323,14 +323,6 @@ dissect_bson_document(tvbuff_t *tvb, packet_info *pinfo, guint offset, proto_tre proto_tree_add_item(doc_tree, hf_mongo_document_length, tvb, offset, 4, ENC_LITTLE_ENDIAN); - unsigned nest_level = p_get_proto_depth(pinfo, proto_mongo); - if (++nest_level > BSON_MAX_NESTING) { - expert_add_info_format(pinfo, ti, &ei_mongo_document_recursion_exceeded, "BSON document recursion exceeds %u", BSON_MAX_NESTING); - /* return the number of bytes we consumed, these are at least the 4 bytes for the length field */ - return MAX(4, document_length); - } - p_set_proto_depth(pinfo, proto_mongo, nest_level); - if (document_length < 5) { expert_add_info_format(pinfo, ti, &ei_mongo_document_length_bad, "BSON document length too short: %u", document_length); return MAX(4, document_length); /* see the comment above */ @@ -348,6 +340,14 @@ dissect_bson_document(tvbuff_t *tvb, packet_info *pinfo, guint offset, proto_tre return document_length; } + unsigned nest_level = p_get_proto_depth(pinfo, proto_mongo); + if (++nest_level > BSON_MAX_NESTING) { + expert_add_info_format(pinfo, ti, &ei_mongo_document_recursion_exceeded, "BSON document recursion exceeds %u", BSON_MAX_NESTING); + /* return the number of bytes we consumed, these are at least the 4 bytes for the length field */ + return MAX(4, document_length); + } + p_set_proto_depth(pinfo, proto_mongo, nest_level); + final_offset = offset + document_length; offset += 4; |