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

Function truncateAtValueBoundary

json_fuzz_test.go:571–583  ·  view source on GitHub ↗

truncateAtValueBoundary cuts the document right after a ':' (before the value starts). This is the OSS-Fuzz 4649128545288192 / sentinel_value_boundary class: the parser must not dereference past the cut when looking for the value token.

(r *rand.Rand, data []byte)

Source from the content-addressed store, hash-verified

569// sentinel_value_boundary class: the parser must not dereference past the
570// cut when looking for the value token.
571func truncateAtValueBoundary(r *rand.Rand, data []byte) []byte {
572 pos := findStructuralBytes(data, ':')
573 if len(pos) == 0 {
574 return data
575 }
576 cut := pos[r.Intn(len(pos))] + 1
577 if cut > len(data) {
578 cut = len(data)
579 }
580 out := make([]byte, cut)
581 copy(out, data[:cut])
582 return out
583}
584
585// truncateMidKey cuts inside a string key. The cut is placed between the
586// opening '"' of a key and its closing '"'. This is the truncated_mid_key

Callers

nothing calls this directly

Calls 1

findStructuralBytesFunction · 0.85

Tested by

no test coverage detected