Skip to content

Commit aefb562

Browse files
committed
skip invalid COBS bytes
1 parent fc6fa9a commit aefb562

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/commands/logs.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,19 @@ pub fn cmd_logs(args: &LogsArgs) -> Result<()> {
4040
}
4141
}
4242

43+
// Given the binary stream so far, read the first COBS frame and return the rest of bytes.
4344
fn advance(chunk: &[u8]) -> (Vec<u8>, &[u8]) {
45+
// Skip the partial frame: all bytes before the separator.
46+
let maybe = chunk.iter().enumerate().find(|(_, b)| **b == 0x00);
47+
let Some((start, _)) = maybe else {
48+
return (Vec::new(), chunk);
49+
};
50+
let chunk = &chunk[start..];
51+
4452
let max_len = chunk.len();
4553
let mut out_buf = vec![0; max_len];
4654
let mut dec = cobs::CobsDecoder::new(&mut out_buf);
47-
match dec.push(chunk) {
55+
match dec.push(&chunk[1..]) {
4856
Ok(Some((n_out, n_in))) => {
4957
let msg = Vec::from(&out_buf[..n_out]);
5058
(msg, &chunk[n_in..])

0 commit comments

Comments
 (0)