1
Fork 0

Return an error (instead of panicking) when cobs_decoded is too short.

This commit is contained in:
Alex Helfet 2019-04-13 17:25:13 +01:00
parent 5bdc84a6c3
commit 2bcb442fba

View file

@ -292,6 +292,9 @@ impl Codec {
.map_err(|_| Error::CobsDecodeFailed)?
};
let cobs_decoded = &dest[0..cobs_decoded_len];
if cobs_decoded_len < self.checksum().len() {
return Err(Error::EofDuringFrame);
}
let payload = &cobs_decoded[0..cobs_decoded_len - self.checksum().len()];
#[cfg(feature = "trace")] {