BurntSushi / toml

TOML parser for Golang with reflection.
MIT License
4.59k stars 529 forks source link

panic: interface conversion: interface {} is int64 #403

Closed manunio closed 10 months ago

manunio commented 10 months ago

Description

Hi, oss-fuzz reported following bug: ASSERT: interface conversion: interface {} is int64, not map[string]interface {} https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=64915 (need an google account to access this and that email must be added to oss-fuzz configuration)

Steps to reproduce

func Test64915(t *testing.T) {
    var v any
    data := "J={D.J=2,D=2,D.K=2"
    _, err := Decode(string(data), &v)
    if err != nil {
        fmt.Println(err)
    }
}
❯ go test -run=Test64915

--- FAIL: Test64915 (0.00s)
panic: interface conversion: interface {} is int64, not map[string]interface {} [recovered]
        panic: interface conversion: interface {} is int64, not map[string]interface {} [recovered]
        panic: interface conversion: interface {} is int64, not map[string]interface {}

goroutine 6 [running]:
testing.tRunner.func1.2({0x5fb120, 0xc00007ec30})
        /home/maxx/.gimme/versions/go1.19.linux.amd64/src/testing/testing.go:1396 +0x24e
testing.tRunner.func1()
        /home/maxx/.gimme/versions/go1.19.linux.amd64/src/testing/testing.go:1399 +0x39f
panic({0x5fb120, 0xc00007ec30})
        /home/maxx/.gimme/versions/go1.19.linux.amd64/src/runtime/panic.go:884 +0x212
github.com/BurntSushi/toml.parse.func1()
        /home/maxx/dev/security/oss-fuzz-projects/burntsushi-toml/parse.go:44 +0x1b6
panic({0x5fb120, 0xc00007ec30})
        /home/maxx/.gimme/versions/go1.19.linux.amd64/src/runtime/panic.go:884 +0x212
github.com/BurntSushi/toml.(*parser).valueInlineTable(0xc000150000, {0x16, {0xc0000201e0, 0x0}, {0x0, 0x0}, {0x1, 0x3, 0x1}}, 0x0)
        /home/maxx/dev/security/oss-fuzz-projects/burntsushi-toml/parse.go:488 +0xe85
github.com/BurntSushi/toml.(*parser).value(0x8120d8?, {0x16, {0xc0000201e0, 0x0}, {0x0, 0x0}, {0x1, 0x3, 0x1}}, 0x0)
        /home/maxx/dev/security/oss-fuzz-projects/burntsushi-toml/parse.go:275 +0x66f
github.com/BurntSushi/toml.(*parser).topLevel(0xc000150000, {0x13, {0xc0000201e0, 0x0}, {0x0, 0x0}, {0x1, 0x0, 0x1}})
        /home/maxx/dev/security/oss-fuzz-projects/burntsushi-toml/parse.go:211 +0xada
github.com/BurntSushi/toml.parse({0xc0000201e0, 0x12})
        /home/maxx/dev/security/oss-fuzz-projects/burntsushi-toml/parse.go:87 +0x513
github.com/BurntSushi/toml.(*Decoder).Decode(0xc000061df0, {0x5e59c0?, 0xc000064a40?})
        /home/maxx/dev/security/oss-fuzz-projects/burntsushi-toml/decode.go:151 +0x48a
github.com/BurntSushi/toml.Decode({0x636f6d, 0x12}, {0x5e59c0, 0xc000064a40})
        /home/maxx/dev/security/oss-fuzz-projects/burntsushi-toml/decode.go:36 +0x115
github.com/BurntSushi/toml.Test64915(0x0?)
        /home/maxx/dev/security/oss-fuzz-projects/burntsushi-toml/decode_test.go:1151 +0x51
testing.tRunner(0xc0001364e0, 0x669f70)
        /home/maxx/.gimme/versions/go1.19.linux.amd64/src/testing/testing.go:1446 +0x10b
created by testing.(*T).Run
        /home/maxx/.gimme/versions/go1.19.linux.amd64/src/testing/testing.go:1493 +0x35f
exit status 2
FAIL    github.com/BurntSushi/toml      0.005s

Tested against 4223137ff1f96bc65e65b11b6deff32052b127bb

❯ git rev-parse HEAD
4223137ff1f96bc65e65b11b6deff32052b127bb
arp242 commented 10 months ago

Thanks; should be fixed now.