Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/mongo/protocol/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def self.deserialize(io, max_message_size = MAX_MESSAGE_SIZE)

# Protection from potential DOS man-in-the-middle attacks. See
# DRIVERS-276.
if length > max_message_size
if length > (max_message_size || MAX_MESSAGE_SIZE)
raise Error::MaxMessageSize.new(max_message_size)
end

Expand Down
13 changes: 13 additions & 0 deletions spec/mongo/protocol/reply_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,19 @@
end
end

context 'when the max message size is nil' do

let(:reply) { described_class.deserialize(io, nil) }

let(:length) { Mongo::Protocol::Message::MAX_MESSAGE_SIZE + 1 }

it 'uses the default max message size for comparison' do
expect {
reply
}.to raise_error(Mongo::Error::MaxMessageSize)
end
end

describe 'response flags' do

context 'no flags' do
Expand Down