Issue 1182: Fix fuzzing bug (#1183)

This patch fixes a fuzzing bug by resolving a bad fallthrough in the
setComment logic.

The result is that we get a proper error instead of an assert, making
the library friendlier to use and less likely to cause issue for
consumers.

See related Chromium project bug:
https://bugs.chromium.org/p/chromium/issues/detail?id=989851

Issue: 1182
This commit is contained in:
Jordan Bayles 2020-05-30 20:20:20 -07:00 committed by GitHub
parent 6aba23f4a8
commit 9be5895985
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -1175,8 +1175,11 @@ bool OurReader::readToken(Token& token) {
if (features_.allowSingleQuotes_) { if (features_.allowSingleQuotes_) {
token.type_ = tokenString; token.type_ = tokenString;
ok = readStringSingleQuote(); ok = readStringSingleQuote();
} else {
// If we don't allow single quotes, this is a failure case.
ok = false;
}
break; break;
} // else fall through
case '/': case '/':
token.type_ = tokenComment; token.type_ = tokenComment;
ok = readComment(); ok = readComment();

View File

@ -0,0 +1 @@
{'//this is bad JSON.'}