aboutsummaryrefslogtreecommitdiff
path: root/src/lib/protocols/mongodb.c
diff options
context:
space:
mode:
authorIvan Nardi <12729895+IvanNardi@users.noreply.github.com>2022-01-29 09:18:32 +0100
committerGitHub <noreply@github.com>2022-01-29 09:18:32 +0100
commit0c70411b1b093279f3d7c09b2b57b491911df84c (patch)
tree993145c834d91aae2cd72044ae940f77557cf713 /src/lib/protocols/mongodb.c
parent86b97ffb73edc0965ee1784c8182e715c2d932e3 (diff)
Make some protocols more "big-endian" friendly (#1402)
See #1312
Diffstat (limited to 'src/lib/protocols/mongodb.c')
-rw-r--r--src/lib/protocols/mongodb.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/lib/protocols/mongodb.c b/src/lib/protocols/mongodb.c
index 09e4662d8..5b462cda2 100644
--- a/src/lib/protocols/mongodb.c
+++ b/src/lib/protocols/mongodb.c
@@ -44,7 +44,7 @@ struct mongo_message_header
uint32_t message_length;
uint32_t request_id;
uint32_t response_to;
- enum mongo_opcodes op_code;
+ uint32_t op_code; /* enum mongo_opcodes */
};
static void set_mongodb_detected(struct ndpi_detection_module_struct *ndpi_struct,
@@ -78,15 +78,15 @@ static void ndpi_check_mongodb(struct ndpi_detection_module_struct *ndpi_struct,
/* All MongoDB numbers are in host byte order */
// mongodb_hdr.message_length = ntohl(mongodb_hdr.message_length);
- if((mongodb_hdr.message_length < 4)
- || (mongodb_hdr.message_length > 1000000) /* Used to avoid false positives */
+ if((le32toh(mongodb_hdr.message_length) < 4)
+ || (le32toh(mongodb_hdr.message_length) > 1000000) /* Used to avoid false positives */
) {
NDPI_LOG_DBG(ndpi_struct, "Invalid MONGODB length");
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
return;
}
- switch(mongodb_hdr.op_code) {
+ switch(le32toh(mongodb_hdr.op_code)) {
case OP_REPLY:
case OP_UPDATE:
case OP_INSERT: