rnithyanand / dpkt

Automatically exported from code.google.com/p/dpkt
Other
0 stars 0 forks source link

Record Fragmentation not handled in TLSMultiFactory(buf) #136

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Send data more than 17000 Bytes. 
2. The TLSMultiFactory will throw an error in finding the TLs version
3. The number of records returned is 0

What is the expected output? What do you see instead?
We should see two records, one with length 16383 and another record with length 
17000-16383

What version of the product are you using? On what operating system?
Dpkt 1.8 and Windows Platform, Win 8.1 64 Bit

Please provide any additional information below.
def TLSMultiFactory(buf):
    '''
    Attempt to parse one or more TLSRecord's out of buf

    Args:
      buf: string containing SSL/TLS messages. May have an incomplete record
        on the end

    Returns:
      [TLSRecord]
      int, total bytes consumed, != len(buf) if an incomplete record was left at
        the end.

    Raises SSL3Exception.
    '''
    i, n = 0, len(buf)
    msgs = []
    while i < n:
        v = buf[i+1:i+3]
        if v in SSL3_VERSION_BYTES:
            try:
                msg = TLSRecord(buf[i:])
                msgs.append(msg)
            except dpkt.NeedData:
                break
        else:
            raise SSL3Exception('Bad TLS version in buf: %r' % buf[i:i+5])
        i += len(msg)
    return msgs, i

I couldn't find the code that handles fragmentation in the Record layer.

Original issue reported on code.google.com by achin...@gmail.com on 13 Nov 2014 at 1:42