move depth increment below error checks
This commit is contained in:
parent
2b43f5f650
commit
24d55ce7ac
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue