Skip to content

Commit fa1ae11

Browse files
baylesjdota17
authored andcommitted
Issue 1182: Fix fuzzing bug (open-source-parsers#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
1 parent 3228be4 commit fa1ae11

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/lib_json/json_reader.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,8 +1192,11 @@ bool OurReader::readToken(Token& token) {
11921192
if (features_.allowSingleQuotes_) {
11931193
token.type_ = tokenString;
11941194
ok = readStringSingleQuote();
1195-
break;
1196-
} // else fall through
1195+
} else {
1196+
// If we don't allow single quotes, this is a failure case.
1197+
ok = false;
1198+
}
1199+
break;
11971200
case '/':
11981201
token.type_ = tokenComment;
11991202
ok = readComment();

test/data/fail_invalid_quote.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{'//this is bad JSON.'}

0 commit comments

Comments
 (0)