mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-03 07:12:28 +00:00
Detect end of input inside an unfinished JSON string
This commit is contained in:
parent
3490090fbc
commit
b1b789df42
@ -0,0 +1 @@
|
|||||||
|
{"qpdf":[{},{"obj:1 0 R":{"stream":{"data":"
|
@ -16,7 +16,7 @@ my @fuzzers = (
|
|||||||
['dct' => 1],
|
['dct' => 1],
|
||||||
['flate' => 1],
|
['flate' => 1],
|
||||||
['hex' => 1],
|
['hex' => 1],
|
||||||
['json' => 39],
|
['json' => 40],
|
||||||
['lzw' => 2],
|
['lzw' => 2],
|
||||||
['pngpredictor' => 1],
|
['pngpredictor' => 1],
|
||||||
['runlength' => 6],
|
['runlength' => 6],
|
||||||
|
@ -628,6 +628,7 @@ namespace
|
|||||||
ls_number_e_sign,
|
ls_number_e_sign,
|
||||||
ls_alpha,
|
ls_alpha,
|
||||||
ls_string,
|
ls_string,
|
||||||
|
ls_after_string,
|
||||||
ls_backslash,
|
ls_backslash,
|
||||||
ls_u4,
|
ls_u4,
|
||||||
ls_begin_array,
|
ls_begin_array,
|
||||||
@ -1039,7 +1040,7 @@ JSONParser::getToken()
|
|||||||
"JSON: offset " + std::to_string(high_offset) +
|
"JSON: offset " + std::to_string(high_offset) +
|
||||||
": UTF-16 high surrogate not followed by low surrogate");
|
": UTF-16 high surrogate not followed by low surrogate");
|
||||||
}
|
}
|
||||||
ignore();
|
ignore(ls_after_string);
|
||||||
return;
|
return;
|
||||||
} else if (*p == '\\') {
|
} else if (*p == '\\') {
|
||||||
ignore(ls_backslash);
|
ignore(ls_backslash);
|
||||||
@ -1234,7 +1235,7 @@ JSONParser::handleToken()
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ls_string:
|
case ls_after_string:
|
||||||
if (parser_state == ps_dict_begin || parser_state == ps_dict_after_comma) {
|
if (parser_state == ps_dict_begin || parser_state == ps_dict_after_comma) {
|
||||||
dict_key = token;
|
dict_key = token;
|
||||||
dict_key_offset = token_start;
|
dict_key_offset = token_start;
|
||||||
|
@ -134,6 +134,12 @@ test_main()
|
|||||||
" \"normal\": \"string\"\n"
|
" \"normal\": \"string\"\n"
|
||||||
"}");
|
"}");
|
||||||
|
|
||||||
|
try {
|
||||||
|
JSON::parse("\"");
|
||||||
|
assert(false);
|
||||||
|
} catch (std::runtime_error&) {
|
||||||
|
}
|
||||||
|
|
||||||
// Check default constructed JSON object (order as per JSON.hh).
|
// Check default constructed JSON object (order as per JSON.hh).
|
||||||
JSON uninitialized;
|
JSON uninitialized;
|
||||||
std::string ws;
|
std::string ws;
|
||||||
|
Loading…
Reference in New Issue
Block a user