[go: up one dir, main page]

Skip to content

Possible panic in recv functions on no_std

I just got the panic:

ERROR panicked at {{path to cargo registry}}/mavio-0.4.2/src/protocol/frame.rs:473:39:
range end index 269 out of range for slice of length 268

Which (for me on no_std) is a line that looks like this:

/*472*/ let mut body_buf = [0u8; crate::consts::PAYLOAD_MAX_SIZE + SIGNATURE_LENGTH];
/*473*/ let body_bytes = &mut body_buf[0..body_length];

Shouldn't the buffer length also contain the checksum size?

self.payload_length as usize + CHECKSUM_SIZE + SIGNATURE_LENGTH

The odd thing is that I do not expect to receive signed messages, or even messages all that large, but perhaps one was just corrupted enough to hit this edge case, as I have never experienced it before.