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

Function recordCrash

fuzz_native_test.go:83–101  ·  view source on GitHub ↗
(target string, panicVal interface{}, stack, input []byte)

Source from the content-addressed store, hash-verified

81}
82
83func recordCrash(target string, panicVal interface{}, stack, input []byte) {
84 panicMsg := fmt.Sprintf("%v", panicVal)
85 sig := crashSignature(panicMsg, stack)
86 fname := filepath.Join(fuzzCrashDir, target+"_"+sig+".json")
87 f, err := os.OpenFile(fname, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0o644)
88 if err != nil {
89 return
90 }
91 defer f.Close()
92 inputCopy := make([]byte, len(input))
93 copy(inputCopy, input)
94 _ = json.NewEncoder(f).Encode(map[string]interface{}{
95 "target": target,
96 "sig": sig,
97 "panic": panicMsg,
98 "stack": string(stack),
99 "input_b64": base64.StdEncoding.EncodeToString(inputCopy),
100 })
101}
102
103func runWithCapture(target string, data []byte, fn func([]byte)) {
104 defer func() {

Callers 1

runWithCaptureFunction · 0.85

Calls 1

crashSignatureFunction · 0.85

Tested by

no test coverage detected