panic: runtime error: index out of range in (*Decoder).string
- Langage dominant
- Go
- Étoiles
- 599
- Forks
- 15
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
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
```
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- go
- Domaine
- compilers
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 55/100