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

prevent ndarray dimension vector from recusive array, nlohmann/json#3500 (#3502)

This commit is contained in:
Qianqian Fang
2022-05-20 03:41:51 -04:00
committed by GitHub
parent 6ff2ea3aed
commit 41226d0a03
3 changed files with 18 additions and 4 deletions

View File

@ -10421,7 +10421,7 @@ class binary_reader
{
std::pair<std::size_t, char_int_type> size_and_type;
size_t dimlen = 0;
bool is_ndarray = false;
bool is_ndarray = true;
if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_type(size_and_type)))
{
@ -10477,7 +10477,6 @@ class binary_reader
*/
bool get_ubjson_size_value(std::size_t& result, bool& is_ndarray, char_int_type prefix = 0)
{
is_ndarray = false;
if (prefix == 0)
{
prefix = get_ignore_noop();
@ -10611,6 +10610,10 @@ class binary_reader
{
break;
}
if (is_ndarray) // ndarray dimensional vector can only contain integers, and can not embed another array
{
return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, exception_message(input_format, "ndarray dimention vector can only contain integers", "size"), nullptr));
}
std::vector<size_t> dim;
if (JSON_HEDLEY_UNLIKELY(!get_ubjson_ndarray_size(dim)))
{