Fix DTLS handling of multiple records in a packet.

9a41d1b946c17f353c1f7f1d35713b5623dc399e broke handling of multiple records in
a single packet. If |extend| is true, not all of the previous packet should be
consumed, only up to the record length.

Add a test which stresses the DTLS stack's handling of multiple handshake
fragments in a handshake record and multiple handshake records in a packet.

Change-Id: I96571098ad9001e96440501c4730325227b155b8
Reviewed-by: Adam Langley <>
4 files changed