pfalcon / uzlib

Radically unbloated DEFLATE/zlib/gzip compression/decompression library. Can decompress any gzip/zlib data, and offers simplified compressor which produces gzip-compatible output, while requiring much less resources (and providing less compression ratio of course).
Other
303 stars 82 forks source link

run-afl-corpus: Avoid locale-dependent filename sorting #12

Closed jepler closed 6 years ago

jepler commented 6 years ago

.. by ensuring that the "C" locale is used while running this script. This requires sorting the "ref" file which was generated using the collation order of some other locale such as en_US.UTF-8.

Apparently, POSIX promises that shell globs use the locale's collation ordering, but bash is alone (among dash, mksh and zsh) at actually doing this. For discussion, see https://serverfault.com/questions/122737/in-bash-are-wildcard-expansions-guaranteed-to-be-in-order

Without this change, I get a failure when I "sh run-afl-test-corpus.sh" (sh is invoking /bin/dash). With this change, I get success with all 4 sh implementations I tested and regardless of my LANG setting such as LANG=en_US.UTF-8 LANG=zh_CN.UTF-8 LANG=C.UTF-8 LANG=C

pfalcon commented 6 years ago

Yeah, I wondered how stable shell's glob is, and whether I have to use ls -1, or run it thru sort, or whatever. The change looks good. But I'd prefer to squash this into the commit where the script was introduced. Let me know if you'd like credits in the commit message.

jepler commented 6 years ago

no worries about credit, squashing makes perfect sense

pfalcon commented 6 years ago

Squashed as discussed, thanks.