Expand description
How deeply JSON may nest, checked before anything recursive touches it.
Reading JSON (serde_json) and walking it are recursive, so the stack they
need grows with how deeply the text nests arrays and objects. On a laptop
the stack is large and has a guard page. On a microcontroller it is a few
kilobytes with nothing below it, and running off the end silently
overwrites other memory. So the no_std build refuses any JSON text that
nests deeper than NO_STD_MAX_NESTING levels, with a scan of the raw
bytes that uses no recursion, before the text is parsed. Protocol objects
nest about ten levels deep, so real credentials never come near it.
The std build keeps its existing limits (serde_json’s own 128 levels and
the per-input limits elsewhere in the core), so nothing changes there.
Constants§
- NO_
STD_ MAX_ NESTING - The deepest JSON nesting the
no_stdbuild reads:[[1]]nests 2 levels. - TOO_
DEEP - The text of the refusal for JSON nested past
NO_STD_MAX_NESTING.
Functions§
- check_
value - Refuse a JSON value that nests past
NO_STD_MAX_NESTINGin ano_stdbuild (a walk with its own stack, no recursion). For values the caller built or parsed itself. - parse
- Parse JSON text into a
Value, refusing text nested pastNO_STD_MAX_NESTINGin ano_stdbuild before serde_json reads it. Firmware should read every JSON input it hands to the core with this. - too_
deep - The refusal for JSON nested past
NO_STD_MAX_NESTING.