3 ms·
I was wondering how this gets any common chunks at all with the removed file boundaries. Turns out that chunks don't have a set size, just min/max/avg values, s
by viraptor 5y ago
I was wondering how this gets any common chunks at all with the removed file boundaries. Turns out that chunks don't have a set size, just min/max/avg values, so unaligned streams may end up synchronizing. https://github.com/systemd/casync/blob/master/src/cachunker.c https://github.com/systemd/casync/blob/master/src/cachunker.... If I understood that correctly, that's pretty cool.
But looking at the code I'm having strong "nope" feelings. First, because of lines like "q += m, n -= m;". Second, because of int/enum/semantic abuse: `compression_type` may be _CA_COMPRESSION_TYPE_INVALID which I hope is -1, `>= 0` as a known compression type, or `-EAGAIN` as an error. (from https://github.com/systemd/casync/blob/99559cd1d8cea69b30022261b5ed0b8021415654/src/cachunk.c#L55 https://github.com/systemd/casync/blob/99559cd1d8cea69b30022... ) I'd bet that just throwing afl at the decompressor will find issues :( (source - I had this feeling about systemd-resolved and threw afl at it, found issues)
I do like the idea though.
- klysm 5y agoHow hard is it to set up AFL? I’ve never had the opportunity to set up a fuzzer
- viraptor 5y agoDepends on the app / file format. If you can isolate some trivial behaviour on a single file you may not even need to change the app. For example "casync list --store=/var/lib/backup.castr input.caidx" could maybe be used to fuzz the index reading if it doesn't care about looking into the store immediately. And if it does, you could comment out those parts as needed. You can get very fancy with the process, but you can start with "here's your single valid input sample, go!" Check out https://fuzzing-project.org/tutorial3.html https://fuzzing-project.org/tutorial3.html and the AFL guide.
- klysm 5y agoThanks! I'll be looking at using that for some of our code