Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions common/jinja/value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1440,6 +1440,14 @@ const func_builtins & value_undefined_t::get_builtins() const {
//////////////////////////////////


// request-derived JSON is untrusted; cap conversion depth so deeply nested
// payloads throw instead of overflowing the stack
static constexpr size_t k_from_json_max_depth = 128;

static value from_json(const common_json & j, bool mark_input, size_t depth = 0) {
if (depth > k_from_json_max_depth) {
throw std::runtime_error("JSON nesting depth exceeds " + std::to_string(k_from_json_max_depth));
}
// the runtime walks values with recursion, a deeper input overflows the stack
static constexpr int FROM_JSON_MAX_DEPTH = 128;

Expand Down