MCPcopy Create free account
hub / github.com/buger/jsonparser / genDeepNesting

Function genDeepNesting

encoding_json_fuzz_test.go:139–151  ·  view source on GitHub ↗

genDeepNesting returns deeply-nested JSON array bytes. When closed is true the structure is complete ([[[...1...]]]); when false it is left unclosed ([[[..., which is the more dangerous stack-overflow shape because the parser must descend before discovering the missing closers.

(depth int, closed bool)

Source from the content-addressed store, hash-verified

137// ([[[..., which is the more dangerous stack-overflow shape because the
138// parser must descend before discovering the missing closers.
139func genDeepNesting(depth int, closed bool) []byte {
140 buf := make([]byte, 0, depth*2+1)
141 for i := 0; i < depth; i++ {
142 buf = append(buf, '[')
143 }
144 if closed {
145 buf = append(buf, '1')
146 for i := 0; i < depth; i++ {
147 buf = append(buf, ']')
148 }
149 }
150 return buf
151}
152
153// =============================================================================
154// Gate A: NO-PANIC (embedded in every gate via encodingJSONNoPanic)

Callers 5

FuzzJSONStructureAwareFunction · 0.85
TestDoSPerformanceFunction · 0.85
runDeepNestingDepthsFunction · 0.85
runTransformDoSGateFunction · 0.85
FuzzEncodingJSONFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected