Skip to content

Commit

Permalink
Merge dd38c64 into fc7b59d
Browse files Browse the repository at this point in the history
  • Loading branch information
K-Reddy1 committed Jun 4, 2021
2 parents fc7b59d + dd38c64 commit 2c26363
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions dpkt/sctp.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ def unpack(self, buf):
while self.data:
chunk = Chunk(self.data)
l_.append(chunk)
if len(chunk) == 0:
self.data = b''
break
self.data = self.data[len(chunk):]
self.chunks = l_

Expand Down Expand Up @@ -157,3 +160,25 @@ def test_sctp_data_chunk(): # https://github.com/kbandla/dpkt/issues/499

# test packing of the padded chunk
assert bytes(ch) == d[SCTP.__hdr_len__:]



def test_malformed_sctp_data_chunk():
# packet 7964 from '4.pcap' downloaded from https://research.unsw.edu.au/projects/unsw-nb15-dataset
d = (b'\x27\x0f\xe1\xc3\xc2\x73\x4d\x32\x4f\x54\x27\x8c' #header
b'\x0b\x00\x00\x04' #chunk 0, COOKIE_ACK chunk
b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') #chunk 1, malformed DATA chunk, size labeled as 0


sctp = SCTP(d)
assert sctp.chunks
assert len(sctp.chunks) == 2

ch = sctp.chunks[1]
assert ch.type == DATA
assert ch.len == 0
assert len(ch) == 0
assert ch.data == b'\x00\x00'

# no remaining sctp data
assert sctp.data == b''

0 comments on commit 2c26363

Please sign in to comment.