Skip to content

Crash in searchKeys#178

@p4zuu

Description

@p4zuu

The following code makes a panic in searchKeys function:

package fuzz import ( "testing""github.com/buger/jsonparser" ) funcTestFuzzCrasher(t*testing.T){crasher:= []byte(`{{{"":`) jsonparser.GetInt(crasher, "a", "b") }

Here is the panic output

panic: runtime error: index out of range [2] with length 2 goroutine 1 [running]: github.com/buger/jsonparser.searchKeys(0x4010000, 0x6, 0x6, 0xc000088e50, 0x2, 0x2, 0xffffffffffffffff) /Users/thomasleroy/Software/go/src/github.com/buger/jsonparser/parser.go:264 +0xef5 github.com/buger/jsonparser.internalGet(0x4010000, 0x6, 0x6, 0xc000088e50, 0x2, 0x2, 0x0, 0xc000000180, 0xc000088d70, 0x1031f50, ...) /Users/thomasleroy/Software/go/src/github.com/buger/jsonparser/parser.go:876 +0x3b5 github.com/buger/jsonparser.Get(0x4010000, 0x6, 0x6, 0xc000088e50, 0x2, 0x2, 0x1052a72, 0x10442bc, 0x1054ab0, 0xc000088e08, ...) /Users/thomasleroy/Software/go/src/github.com/buger/jsonparser/parser.go:870 +0x8b github.com/buger/jsonparser.GetInt(0x4010000, 0x6, 0x6, 0xc000088e50, 0x2, 0x2, 0x1a22912800000000, 0x5daa1a76, 0xc000088e70) /Users/thomasleroy/Software/go/src/github.com/buger/jsonparser/parser.go:1140 +0x8b _/Users/thomasleroy/Security/Fuzzing/Go-fuzz.Fuzz(0x4010000, 0x6, 0x6, 0x3) /Users/thomasleroy/Security/Fuzzing/Go-fuzz/jsonparser.go:8 +0x95 go-fuzz-dep.Main(0xc000088f48, 0x1, 0x1) go-fuzz-dep/main.go:36 +0x1ad main.main() _/Users/thomasleroy/Security/Fuzzing/Go-fuzz/go.fuzz.main/main.go:15 +0x52 exit status 2 

The function also crashes if you call GetInt(crasher, "a")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions