golang/go

debug/pe: panic on interface conversion

tklauser opened this issue · 1 comments

go version devel +d6c5be54a674 Fri Feb 15 00:00:35 2019 +0100 linux/amd64

package main

import (
        "bytes"
        "debug/pe"
)

func main() {
        data := []byte("\x00\x00\x00\x0000000\x00\x00\x00\x00\x00\x00\x000000" +
                "00000000000000000000" +
                "000000000\x00\x00\x0000000000" +
                "00000000000000000000" +
                "0000000000000000")
        f, err := pe.NewFile(bytes.NewReader(data))
        if err != nil {
                return
        }
        defer f.Close()
        f.ImportedSymbols()
}

go run crash.go

panic: interface conversion: interface {} is nil, not *pe.OptionalHeader32

goroutine 1 [running]:
debug/pe.(*File).ImportedSymbols(0xc0000ba000, 0x4d7598, 0xc0000ba000, 0x0, 0x0, 0x498ba2)
	/go/src/debug/pe/file.go:336 +0xabb
main.main()
	/go/src/github.com/tklauser/go-fuzz-corpus/pe/repro.go:19 +0xf1
exit status 2

Found using go-fuzz (#19109)

Change https://golang.org/cl/162858 mentions this issue: debug/pe: reject invalid optional header size in NewFile