Fix panic on malformed short header

This commit is contained in:
Benjamin Saunders
2020-09-24 17:51:50 -07:00
committed by Dirkjan Ochtman
parent d72bc0fc6f
commit 9eb76ee6bb
+5 -1
View File
@@ -514,7 +514,11 @@ impl PlainHeader {
let first = buf.get::<u8>()?;
if first & LONG_HEADER_FORM == 0 {
let spin = first & SPIN_BIT != 0;
let dst_cid = ConnectionId::new(&buf.bytes()[..local_cid_len]);
let dst_cid = ConnectionId::new(
&buf.bytes()
.get(..local_cid_len)
.ok_or(PacketDecodeError::InvalidHeader("cid out of bounds"))?,
);
buf.advance(local_cid_len);
Ok(PlainHeader::Short {