[DRIVERS-276] Drivers must raise an error if response messageLength > ismaster.maxMessageSizeBytes Created: 23/Nov/15  Updated: 09/May/22  Resolved: 09/May/22

Status: Closed
Project: Drivers
Component/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Hannes Magnusson Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on MOTOR-179 Drivers must raise an error if respon... Closed
depends on GODRIVER-150 Drivers must raise an error if respon... Closed
depends on RUST-616 Drivers must raise an error if respon... Closed
Related
related to CDRIVER-1023 Support reading 16mb using the new fi... Closed
is related to DRIVERS-275 Drivers should check encoded operatio... Closed
is related to CXX-773 Drivers must raise an error if respon... Closed
is related to CXX-776 Drivers must raise an error if respon... Closed
is related to JAVA-2062 Check for corrupted OP_REPLY message ... Closed
is related to NODE-620 Drivers must raise an error if respon... Closed
is related to PHPC-503 Drivers must raise an error if respon... Closed
is related to PHPLIB-150 Drivers must raise an error if respon... Closed
is related to PYTHON-1029 Drivers must raise an error if respon... Closed
is related to RUBY-1076 Drivers must raise an error if respon... Closed
is related to CSHARP-1501 Drivers must raise an error if respon... Closed
Driver Changes: Needed
Driver Compliance:
Key Status/Resolution FixVersion
MOTOR-179 Fixed
GODRIVER-150 Fixed 1.5.0
SWIFT-1032 Won't Do
RUST-616 Fixed 2.3.0

 Description   

When reading a response from the server, if header.messageLength is greater than ismaster.maxMessageSizeBytes a driver MUST raise an error and close the connection.

If this is the first operation run on the server (e.g. the first ismaster command sent on first connection) use a hard coded value of 48MB, switching to ismaster.maxMessageSizeBytes once you have received a valid ismaster response.

Original bug report continues below
---------------------------------------------

The new find() command in MongoDB 3.2 can return documents that are larger then the configured maxBsonObjectSize (16777216 bytes).

Drivers that validate the messageLength header from the server need to adjust their validation accordingly.

I suggest we use the same logic as the server, which is rumored to do:
maxBsonObjectSize + 16K



 Comments   
Comment by Jeremy Mikola [ 04/Oct/16 ]

PHPC and HHVM rely on libmongoc.

Does not apply to PHPLIB and there are no plans to validate this for the legacy PHP driver.

Comment by Andrew Morrow (Inactive) [ 22/Dec/15 ]

C++11 driver relies on C driver for this functionality

Comment by Bernie Hackett [ 23/Nov/15 ]

bjori, perhaps ismaster.maxMessageSizeBytes is a better value? I don't think the server would ever return an OP_REPLY message anywhere near that large, but at least you're using a value defined by the server.

Comment by Bernie Hackett [ 23/Nov/15 ]

+ OP_REPLY overhead? I assume in the C driver you're counting the total number of bytes read in response?

Generated at Thu Feb 08 08:21:09 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.