[QFJ-376] When a lot of bad data is pumped into the QF/J, it does nothing Created: 25/Nov/08  Updated: 11/Feb/09  Resolved: 26/Nov/08

Status: Closed
Project: QuickFIX/J
Component/s: None
Affects Version/s: 1.3.3
Fix Version/s: 1.4.0

Type: Bug Priority: Default
Reporter: aleksey ratushnyy Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None


 Description   

Setup: QuickFix/J acceptor listening on a port.

Test case: connect to the port on which the acceptor is listening via telnet and pump the data from /dev/zero (telnet HOST PORT < /dev/zero & )

What happens?
The server is DOS'ed into an eventual OutOfMemoryError

Why?
In MINA,
org.apache.mina.filter.codec.CumulativeProtocolDecoder.decode() accumulates the data in a session buffer until it is processed.
org.apache.mina.filter.codec.demux.DemuxingProtocolCodecFactory.ProtocolDecoderImpl.doDecode() is called to process the data.
It calls org.apache.mina.filter.codec.demux.MessageDecoder.decodable() method to identify which protocol to use.

In QuickFix/J,
quickfix.mina.message.FIXMessageDecoder.decodable() keeps iterating over and over again over ever increasing ByteBuffer, and keeps returning MessageDecoderResult.NEED_DATA.

What I think should be done to fix it:
quickfix.mina.message.FIXMessageDecoder.decodable() should instead return MessageDecoderResult.NOT_OK after the length of the unprocessed data grows beyond certain reasonable length comparable with the HEADER_PATTERN's potential max length. This would cause MINA to throw ProtocolDecoderException and the connection to be shut down.


Generated at Sat May 18 20:05:23 UTC 2024 using JIRA 7.5.2#75007-sha1:9f5725bb824792b3230a5d8716f0c13e296a3cae.