| 309 | static bool json_bool(const char **p, bool *out) { |
| 310 | json_ws(p); |
| 311 | if (json_lit(p, "true")) { |
| 312 | *out = true; |
| 313 | return true; |
| 314 | } |
| 315 | if (json_lit(p, "false")) { |
| 316 | *out = false; |
| 317 | return true; |
| 318 | } |
| 319 | return false; |
| 320 | } |
| 321 | |
| 322 | /* The request parser only understands the API fields we use and skips the |
| 323 | * rest. Skipping is recursive because JSON values nest, so keep an explicit |
| 324 | * ceiling: without it, a useless ignored field like {"x":[[[...]]]} can spend |
| 325 | * the whole C stack before the request is rejected. */ |
| 326 | #define JSON_MAX_NESTING 256 |
| 327 | |
| 328 | static bool json_skip_value_depth(const char **p, int depth); |
| 329 | |
| 330 | static bool json_skip_array_depth(const char **p, int depth) { |
| 331 | if (depth >= JSON_MAX_NESTING) return false; |
| 332 | json_ws(p); |
| 333 | if (**p != '[') return false; |
| 334 | (*p)++; |
no test coverage detected