a8m / a8m/djson

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

Aperta
#5 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Go
Stelle
599
Fork
15
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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
```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

The crash occurs in decode.go line 224 in the (*Decoder).string method. Start by examining the string parsing logic around that line to understand how index bounds are checked. The test case in fuzzer_test.go provides a minimal reproducing input. Run the test to confirm the panic, then trace through the nested object parsing to see where the index goes out of range.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
go
Ambito
compilers
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
55/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.