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

Function checkOffsetBoundsGate

json_fuzz_test.go:1088–1096  ·  view source on GitHub ↗

checkOffsetBoundsGate (Gate 5: OFFSET-BOUNDS) asserts that Get's offset return is within the documented range [-1, len(data)]. Per SYS-REQ-016 / SYS-REQ-019, not-found returns offset=-1; per SYS-REQ-001 success returns a value-end offset in [0, len(data)]. An offset outside this range is an OOB inde

(t *testing.T, data []byte, path []string)

Source from the content-addressed store, hash-verified

1086//
1087// Cheap (one comparison); no size cap needed.
1088func checkOffsetBoundsGate(t *testing.T, data []byte, path []string) {
1089 t.Helper()
1090 _, _, offset, _ := Get(data, path...)
1091 if offset < -1 || offset > len(data) {
1092 t.Errorf("Get returned out-of-bounds offset %d (len=%d): "+
1093 "data=%q path=%v (OFFSET-BOUNDS violation)",
1094 offset, len(data), data, path)
1095 }
1096}
1097
1098// checkDeterminismGate (Gate 6: DETERMINISM) asserts that two Get calls on
1099// the same input+path return byte-identical (value, type, offset) and the

Callers 1

runStructureAwareGatesFunction · 0.85

Calls 1

GetFunction · 0.85

Tested by

no test coverage detected