MCPcopy Create free account
hub / github.com/antirez/ds4 / json_skip_array_depth

Function json_skip_array_depth

ds4_server.c:311–331  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

309static 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
328static bool json_skip_value_depth(const char **p, int depth);
329
330static 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)++;

Callers 1

json_skip_value_depthFunction · 0.85

Calls 2

json_wsFunction · 0.85
json_skip_value_depthFunction · 0.85

Tested by

no test coverage detected