debug/pe: add FuzzReader

Add the testdata binaries and the reproducers for #30250 and #30253 to
the seed corpus.

Change-Id: I12e4f48a9a4bb91f00f1703cd7b2776eb2bf2e5d
Reviewed-on: https://go-review.googlesource.com/c/go/+/780360
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
This commit is contained in:
Tobias Klauser 2026-05-20 18:08:55 +02:00 committed by Gopher Robot
parent 71300e8011
commit 3c05d2a519
4 changed files with 69 additions and 0 deletions

63
src/debug/pe/fuzz_test.go Normal file
View file

@ -0,0 +1,63 @@
// Copyright 2026 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package pe_test
import (
"bytes"
"debug/pe"
"os"
"path/filepath"
"testing"
)
func FuzzReader(f *testing.F) {
if testing.Short() {
f.Skip("Skipping in short mode")
}
testdata, err := os.ReadDir("testdata")
if err != nil {
f.Fatalf("failed to read testdata directory: %s", err)
}
for _, de := range testdata {
if de.IsDir() || filepath.Ext(de.Name()) == ".c" {
continue
}
b, err := os.ReadFile(filepath.Join("testdata", de.Name()))
if err != nil {
f.Fatalf("failed to read testdata: %s", err)
}
f.Add(b)
}
f.Fuzz(func(t *testing.T, data []byte) {
f, err := pe.NewFile(bytes.NewReader(data))
if err != nil {
return
}
defer f.Close()
f.ImportedLibraries()
f.ImportedSymbols()
f.Section(".data")
f.Section(".text")
for _, c := range f.COFFSymbols {
_, err := c.FullName(f.StringTable)
if err != nil {
continue
}
}
dw, err := f.DWARF()
if err != nil {
return
}
dr := dw.Reader()
for {
e, _ := dr.Next()
if e == nil {
break
}
}
})
}

View file

@ -0,0 +1,2 @@
go test fuzz v1
[]byte("\x00\x00\x00\x0000000\x00\x00\x00\x00\x00\x00\x00000000000000000000000000000000000\x00\x00\x0000000000000000000000000000000000000000000000")

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,2 @@
go test fuzz v1
[]byte("L\x01\b\x00regi\x00\x00\x00\x00\x00\x00\x00\x00\xe0\x00\x0f\x03\v\x01\x02\x18\x00\x0e\x00\x00\x00\x1e\x00\x00\x00\x02\x00\x00\x80\x12\x00\x00\x00\x10\x00\x00\x00 \x00\x00\x00\x00@\x00\x00\x10\x00\x00\x00\x02\x00\x00\x04\x00\x00\x00\x01\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x90\x00\x00\x00\x04\x00\x00\x06S\x00\x00\x03\x00\x00\x00\x00\x00 \x00\x00\x10\x00\x00\x00\x00\x10\x00\x00\x10\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00`\x00\x00x\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x80\x00\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xb8`\x00\x00|\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00.text\x00\x00\x00d\f\x00\x00\x00\x10\x00\x00\x00\x0e\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00`\x00P`.data\x00\x00\x00\x10\x00\x00\x00\x00 \x00\x00\x00\x02\x00\x00\x00\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00@\x000\xc0.rdata\x00\x004\x01\x00\x00\x000\x00\x00\x00\x02\x00\x00\x00\x14\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00@\x000@.eh_fram\xa0\x03\x00\x00\x00@\x00\x00\x00\x04\x00\x00\x00\x16\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00@\x000@.bss\x00\x00\x00\x00`\x00\x00\x00\x00P\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x000\xc0.idata\x00\x00x\x03\x00\x00\x00`\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00@\x000\xc0.CRT\x00\x00\x00\x00\x18\x00\x00\x00\x00p\x00\x00\x00\x02\x00\x00\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00@\x000\xc0.tls\x00\x00\x00\x00 \x00\x00\x00\x00\x80\x00\x00\x00\x02\x00\x00\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x001\xc9H\x895\x1d")