Skip to content

Commit 249ad9f

Browse files
committed
stackLimit
1 parent 99b8e85 commit 249ad9f

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

include/json/reader.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,9 @@ class JSON_API CharReaderBuilder : public CharReader::Factory {
310310
- true if dropped null placeholders are allowed. (See StreamWriterBuilder.)
311311
- "allowNumericKeys": false or true
312312
- true if numeric object keys are allowed.
313+
- "stackLimit": integer
314+
- This is a security issue (seg-faults caused by deeply nested JSON),
315+
so the default is low.
313316
314317
You can examine 'settings_` yourself
315318
to see the defaults. You can also write and read them just like any

src/lib_json/json_reader.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1865,6 +1865,7 @@ static void getValidReaderKeys(std::set<std::string>* valid_keys)
18651865
valid_keys->insert("strictRoot");
18661866
valid_keys->insert("allowDroppedNullPlaceholders");
18671867
valid_keys->insert("allowNumericKeys");
1868+
valid_keys->insert("stackLimit");
18681869
}
18691870
bool CharReaderBuilder::validate(Json::Value* invalid) const
18701871
{
@@ -1903,6 +1904,7 @@ void CharReaderBuilder::setDefaults(Json::Value* settings)
19031904
(*settings)["strictRoot"] = false;
19041905
(*settings)["allowDroppedNullPlaceholders"] = false;
19051906
(*settings)["allowNumericKeys"] = false;
1907+
(*settings)["stackLimit"] = 1000;
19061908
//! [CharReaderBuilderDefaults]
19071909
}
19081910

0 commit comments

Comments
 (0)