Ticket #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)