cobs.rs
cobs.rs copied to clipboard
Encoding empty data is broken
I've raised it in this comment too: https://github.com/jamesmunns/cobs.rs/issues/16#issuecomment-2676167268
The encoder encodes an empty input as empty output. That is not correct, according to the COBS paper, an empty string encodes into 0x01.
This is not an opinionated thing to do or not to do as the previously linked thread mentions, this is a protocol violation that needs to be fixed. You cannot expect every single one of your users to add special case hacks because the library fails to honour the specs.
In the same vein, calculating the max encoding length is similarly broken, it returns 0 for an empty input instead of the required 1. This causes further pain requiring special casing all over.
I am using this crate again and might look into this.