#2197 defect new
[SIP] wrong assertion in MessagesParser.dataDone
|Reported by:||antoine||Owned by:||washort|
|Cc:||therve, exarkun, awclinford@…||Branch:|
At the end of the method twisted.protocols.sip:MessagesParser.dataDone(), the number of currently received bytes is compared to the declared content-length. The stated aim is to distinguish "aborted" packets/datagrams (received bytes < content length) from internal errors.
However, the comparison in line 533 does exactly the reverse, and raises a RuntimeError when an "aborted" packet is received.
To fix the bug, "self.length < self.bodyReceived" in that line must be changed to "self.length > self.bodyReceived".
To test for this behaviour, add the following method to MessageParsingTestCase in test_sip.py:
def testIncomplete(self): # test for "aborted" request (body shorter than content-length) l = self.l self.feedMessage(request4[:-1]) self.assertEquals(len(l), 2)
Change History (10)
Changed 8 years ago by therve
comment:1 Changed 8 years ago by therve
- Cc therve added
- Keywords review added
- Owner glyph deleted
- Priority changed from normal to highest
comment:2 follow-ups: ↓ 3 ↓ 4 Changed 8 years ago by exarkun
- Cc exarkun added
- Keywords review removed
- Owner set to washort