Skip to content

panic: runtime error: index out of range in (*Decoder).string #5

@gy741

Description

@gy741

Hello.

I found a index out of range bug in djson.

Please confirm.

Thanks.

reproduce code:

package djson

import (
	"testing"
)

func TestFuzzCrashers(t *testing.T) {

	var crashers = []string{
			"{\"\":{\"\":{\"\":{\"\":{\"\":" +
			"{\"\\",
	}

	for _, f := range crashers {
		Decode([]byte(f))
	}
}

Crash Log:

--- FAIL: TestFuzzCrashers (0.00s)
panic: runtime error: index out of range [recovered]
	panic: runtime error: index out of range

goroutine 16 [running]:
panic(0x513c80, 0xc42000a120)
	/usr/lib/go-1.7/src/runtime/panic.go:500 +0x1a1
testing.tRunner.func1(0xc4200689c0)
	/usr/lib/go-1.7/src/testing/testing.go:579 +0x25d
panic(0x513c80, 0xc42000a120)
	/usr/lib/go-1.7/src/runtime/panic.go:458 +0x243
github.com/a8m/djson.(*Decoder).string(0xc42003eec0, 0x0, 0xc420013380, 0x0, 0xc420013380)
	/home/karas/go/src/github.com/a8m/djson/decode.go:224 +0x2f5
github.com/a8m/djson.(*Decoder).object(0xc420035eb0, 0xe, 0x0, 0x0)
	/home/karas/go/src/github.com/a8m/djson/decode.go:384 +0x11b
github.com/a8m/djson.(*Decoder).any(0xc420035eb0, 0x0, 0x0, 0x0, 0x0)
	/home/karas/go/src/github.com/a8m/djson/decode.go:176 +0x8ff
github.com/a8m/djson.(*Decoder).object(0xc420035eb0, 0x12, 0x0, 0x0)
	/home/karas/go/src/github.com/a8m/djson/decode.go:397 +0x1ac
github.com/a8m/djson.(*Decoder).any(0xc420035eb0, 0x0, 0x0, 0x0, 0x0)
	/home/karas/go/src/github.com/a8m/djson/decode.go:176 +0x8ff
github.com/a8m/djson.(*Decoder).object(0xc420035eb0, 0x16, 0x0, 0x0)
	/home/karas/go/src/github.com/a8m/djson/decode.go:397 +0x1ac
github.com/a8m/djson.(*Decoder).any(0xc420035eb0, 0x0, 0x0, 0x0, 0x0)
	/home/karas/go/src/github.com/a8m/djson/decode.go:176 +0x8ff
github.com/a8m/djson.(*Decoder).object(0xc420035eb0, 0x1a, 0x0, 0x0)
	/home/karas/go/src/github.com/a8m/djson/decode.go:397 +0x1ac
github.com/a8m/djson.(*Decoder).any(0xc420035eb0, 0x0, 0x0, 0x0, 0x0)
	/home/karas/go/src/github.com/a8m/djson/decode.go:176 +0x8ff
github.com/a8m/djson.(*Decoder).object(0xc420035eb0, 0x1e, 0x0, 0x0)
	/home/karas/go/src/github.com/a8m/djson/decode.go:397 +0x1ac
github.com/a8m/djson.(*Decoder).any(0xc420035eb0, 0x0, 0x0, 0x0, 0x0)
	/home/karas/go/src/github.com/a8m/djson/decode.go:176 +0x8ff
github.com/a8m/djson.(*Decoder).object(0xc420035eb0, 0x5cf2a0, 0x100c00000000000, 0x0)
	/home/karas/go/src/github.com/a8m/djson/decode.go:397 +0x1ac
github.com/a8m/djson.(*Decoder).any(0xc420035eb0, 0x100, 0xc420011960, 0x20, 0xc420011960)
	/home/karas/go/src/github.com/a8m/djson/decode.go:176 +0x8ff
github.com/a8m/djson.Decode(0xc420011960, 0x17, 0x20, 0xc420011960, 0x17, 0x20, 0x6d5e5cf)
	/home/karas/go/src/github.com/a8m/djson/interface.go:83 +0x76
github.com/a8m/djson.TestFuzzCrashers(0xc4200689c0)
	/home/karas/go/src/github.com/a8m/djson/fuzzer_test.go:15 +0x84
testing.tRunner(0xc4200689c0, 0x545fc0)
	/usr/lib/go-1.7/src/testing/testing.go:610 +0x81
created by testing.(*T).Run
	/usr/lib/go-1.7/src/testing/testing.go:646 +0x2ec
exit status 2

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