mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2024-12-27 11:21:02 +08:00
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:
parent
6aba23f4a8
commit
9be5895985
@ -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();
|
||||||
|
1
test/data/fail_invalid_quote.json
Normal file
1
test/data/fail_invalid_quote.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{'//this is bad JSON.'}
|
Loading…
x
Reference in New Issue
Block a user