1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-28 12:02:00 +03:00

Handle invalid BJData optimized type, fix #3461 (#3463)

* Handle invalid BJData optimized type, fix #3461

* Update unit test to handle bjdata optimized array type error
This commit is contained in:
Qianqian Fang
2022-05-01 16:47:06 -04:00
committed by GitHub
parent bdc21ad1a7
commit b205361d86
3 changed files with 77 additions and 30 deletions

View File

@ -10652,6 +10652,13 @@ class binary_reader
std::vector<char_int_type> bjdx = {'[', '{', 'S', 'H', 'T', 'F', 'N', 'Z'}; // excluded markers in bjdata optimized type
result.second = get(); // must not ignore 'N', because 'N' maybe the type
if (JSON_HEDLEY_UNLIKELY( input_format == input_format_t::bjdata && std::find(bjdx.begin(), bjdx.end(), result.second) != bjdx.end() ))
{
auto last_token = get_token_string();
return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
exception_message(input_format, concat("marker 0x", last_token, " is not a permitted optimized array type"), "type"), nullptr));
}
if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format, "type") || (input_format == input_format_t::bjdata && std::find(bjdx.begin(), bjdx.end(), result.second) != bjdx.end() )))
{
return false;