cobs.rs icon indicating copy to clipboard operation
cobs.rs copied to clipboard

Encoding empty data is broken

Open karalabe opened this issue 9 months ago • 1 comments

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.

Image

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.

karalabe avatar Feb 22 '25 12:02 karalabe

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.

karalabe avatar Feb 22 '25 12:02 karalabe

I am using this crate again and might look into this.

robamu avatar May 04 '25 09:05 robamu