Skip to content

Centipede: accept utf-8 bytes in AFL dictionaries - #2276

Open
rootkiller6788 wants to merge 2 commits into
google:mainfrom
rootkiller6788:fix-afl-dict-utf8
Open

rootkiller6788 wants to merge 2 commits into
google:mainfrom
rootkiller6788:fix-afl-dict-utf8

Conversation

@rootkiller6788

Copy link
Copy Markdown

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.

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
rootkiller6788 marked this pull request as ready for review October 17, 2026 09:16

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant