panic: runtime error: index out of range in (*Decoder).any
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Ambito
- compilers
Direzione di ricerca
Il crash si verifica in decode.go alla riga 135, in (*Decoder).any. Inizia esaminando il file decode.go, in particolare i metodi any e array. L’input del test è una stringa JSON malformata '[[[[[[[[[-'. Esegui il test fornito per riprodurre il panic, quindi traccia l’accesso all’indice fuori dai limiti. La correzione probabilmente consiste nell’aggiungere un controllo dei limiti quando si accede al buffer di input durante il parsing degli array.
Scritto dal modello di indicizzazione a partire dal testo della issue.
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).any(0xc42003eec0, 0x0, 0x0, 0x5e90a8, 0x0)
/home/karas/go/src/github.com/a8m/djson/decode.go:135 +0x190
github.com/a8m/djson.(*Decoder).array(0xc420035eb0, 0x0, 0x0, 0x0, 0x0, 0xc42003e580)
/home/karas/go/src/github.com/a8m/djson/decode.go:339 +0xe5
github.com/a8m/djson.(*Decoder).any(0xc420035eb0, 0x0, 0x0, 0x5e90a8, 0x0)
/home/karas/go/src/github.com/a8m/djson/decode.go:174 +0x52f
github.com/a8m/djson.(*Decoder).array(0xc420035eb0, 0x0, 0x0, 0x0, 0x0, 0xc42003e6a0)
/home/karas/go/src/github.com/a8m/djson/decode.go:339 +0xe5
github.com/a8m/djson.(*Decoder).any(0xc420035eb0, 0x0, 0x0, 0x5e90a8, 0x0)
/home/karas/go/src/github.com/a8m/djson/decode.go:174 +0x52f
github.com/a8m/djson.(*Decoder).array(0xc420035eb0, 0x0, 0x0, 0x0, 0x0, 0xc42003e7c0)
/home/karas/go/src/github.com/a8m/djson/decode.go:339 +0xe5
github.com/a8m/djson.(*Decoder).any(0xc420035eb0, 0x0, 0x0, 0x5e90a8, 0x0)
/home/karas/go/src/github.com/a8m/djson/decode.go:174 +0x52f
github.com/a8m/djson.(*Decoder).array(0xc420035eb0, 0x5, 0x44, 0x0, 0x5cf2a0, 0xc42003e8e0)
/home/karas/go/src/github.com/a8m/djson/decode.go:339 +0xe5
github.com/a8m/djson.(*Decoder).any(0xc420035eb0, 0x0, 0x0, 0x5e90a8, 0x0)
/home/karas/go/src/github.com/a8m/djson/decode.go:174 +0x52f
github.com/a8m/djson.(*Decoder).array(0xc420035eb0, 0x0, 0x0, 0x0, 0x4b7c4c, 0xc42003ea00)
/home/karas/go/src/github.com/a8m/djson/decode.go:339 +0xe5
github.com/a8m/djson.(*Decoder).any(0xc420035eb0, 0x0, 0x0, 0x5e90a8, 0x0)
/home/karas/go/src/github.com/a8m/djson/decode.go:174 +0x52f
github.com/a8m/djson.(*Decoder).array(0xc420035eb0, 0xc42003eb48, 0x40eabe, 0xc420068068, 0xc42003eb98, 0xc420023b30)
/home/karas/go/src/github.com/a8m/djson/decode.go:339 +0xe5
github.com/a8m/djson.(*Decoder).any(0xc420035eb0, 0x0, 0x0, 0x5e90a8, 0x0)
/home/karas/go/src/github.com/a8m/djson/decode.go:174 +0x52f
github.com/a8m/djson.(*Decoder).array(0xc420035eb0, 0x0, 0x0, 0x0, 0x0, 0xc420023c50)
/home/karas/go/src/github.com/a8m/djson/decode.go:339 +0xe5
github.com/a8m/djson.(*Decoder).any(0xc420035eb0, 0x0, 0x0, 0x5e90a8, 0x0)
/home/karas/go/src/github.com/a8m/djson/decode.go:174 +0x52f
github.com/a8m/djson.(*Decoder).array(0xc420035eb0, 0x0, 0xc420023d58, 0x4ba55a, 0xc420068000, 0xc420023d70)
/home/karas/go/src/github.com/a8m/djson/decode.go:339 +0xe5
github.com/a8m/djson.(*Decoder).any(0xc420035eb0, 0x0, 0x0, 0x5e90a8, 0x0)
/home/karas/go/src/github.com/a8m/djson/decode.go:174 +0x52f
github.com/a8m/djson.(*Decoder).array(0xc420035eb0, 0x5cf2a0, 0x100c00000000000, 0x0, 0x10, 0xc420084170)
/home/karas/go/src/github.com/a8m/djson/decode.go:339 +0xe5
github.com/a8m/djson.(*Decoder).any(0xc420035eb0, 0x100, 0xc420084170, 0x10, 0xc420084170)
/home/karas/go/src/github.com/a8m/djson/decode.go:174 +0x52f
github.com/a8m/djson.Decode(0xc420084170, 0xa, 0x10, 0xc420084170, 0xa, 0x10, 0x66cc677)
/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:14 +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
FAIL github.com/a8m/djson 0.007s
- Lingua principale
- Go
- Stelle
- 599
- Fork
- 15
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di a8m/djson
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 10/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 1/5 1-3 ore Idoneità per principianti 76/100
superplanehq/superplane#9007 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
yetone/magpie#3905 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno