Return an error (instead of panicking) when cobs_decoded is too short.
This commit is contained in:
parent
5bdc84a6c3
commit
2bcb442fba
1 changed files with 3 additions and 0 deletions
|
@ -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")] {
|
||||
|
|
Loading…
Reference in a new issue