Repository navigation
Centipede: accept utf-8 bytes in AFL dictionaries - #2276
Open
rootkiller6788 wants to merge 2 commits into
Open
rootkiller6788 wants to merge 2 commits into
rootkiller6788 wants to merge 2 commits into
Conversation
ParseAFLDictionary bails out if any byte is neither printable nor a space, which is meant to detect a Centipede binary dictionary. But utf-8 in a comment is perfectly normal text, and fuzz_lua.dict from OSS-Fuzz has an en dash in its header comment, so the whole file was rejected and centipede died with "Empty or corrupt dictionary file". Only treat ASCII control characters as the binary marker now, and pass an unsigned char to isprint/isspace.
Covers utf-8 in a comment and in an entry, plus a control byte in an entry so the binary detection is still pinned down. The old \xAB case was never really about non-ascii, that input has no quote at all, so fix its comment.
rootkiller6788
marked this pull request as ready for review
October 17, 2026 09:16
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix for #1675.
centipede can't load fuzz_lua.dict: ParseAFLDictionary() rejects the whole file if any byte is neither printable nor whitespace. That check is there to spot a Centipede binary dictionary, but the Lua dict has a utf-8 en dash in one of its comments, and utf-8 in a comment is just text. The file was rejected, LoadDictionary fell through to the binary reader, and we got the "Empty or corrupt dictionary file" check.
I made the check only care about ASCII control bytes, which is what actually shows up in a binary dictionary, and let bytes above 0x7f through. While there I switched the isprint/isspace arguments to unsigned char - passing a negative char was undefined.
I couldn't build centipede here (no bazel, and the local gcc is too old for absl), so I verified by pulling the two functions out of centipede/util.cc into a small harness with shims for the three absl helpers they use. With the real fuzz_lua.dict: false/0 entries before, true/226 entries after. All 8 existing UtilTest.ParseAFLDictionary cases keep their result, and dictionaries with control bytes or NULs are still rejected.
The tests cover utf-8 in a comment, utf-8 in an entry, and a control byte in an entry.