aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-mongo.c
diff options
context:
space:
mode:
authorMartin Kaiser <wireshark@kaiser.cx>2016-06-15 13:02:39 -0700
committerAnders Broman <a.broman58@gmail.com>2016-06-16 00:09:36 +0000
commitb2c7e8eb013336f3ec28d374a6e1e7cd6abfb234 (patch)
treeaafc1969b6f5984f0147d5acb13d7fa61d4ba55e /epan/dissectors/packet-mongo.c
parentc5528d0b06176e5616b15519b26e071833f3f413 (diff)
mongo: return the number of bytes we actually consumed
even if the document length is 0, we consumed at least 4 bytes for the length field bug: 12534 Change-Id: I2f1612bf575b558c1bcc0afe8202b202747846e3 Reviewed-on: https://code.wireshark.org/review/15934 Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-mongo.c')
-rw-r--r--epan/dissectors/packet-mongo.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/epan/dissectors/packet-mongo.c b/epan/dissectors/packet-mongo.c
index 51e7256326..188a1785e1 100644
--- a/epan/dissectors/packet-mongo.c
+++ b/epan/dissectors/packet-mongo.c
@@ -263,12 +263,13 @@ dissect_bson_document(tvbuff_t *tvb, packet_info *pinfo, guint offset, proto_tre
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 document_length;
+ /* return the number of bytes we consumed, these are at least the 4 bytes for the length field */
+ return MAX(4, document_length);
}
if (document_length < 5) {
expert_add_info_format(pinfo, ti, &ei_mongo_document_length_bad, "BSON document length too short: %u", document_length);
- return document_length;
+ return MAX(4, document_length); /* see the comment above */
}
if (document_length > BSON_MAX_DOC_SIZE) {