[go] debug/pe: avoid panic in File.ImportedSymbols

5 views
Skip to first unread message

Alex Brainman (Gerrit)

unread,
Jun 27, 2025, 12:42:53 AMJun 27
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Alex Brainman has uploaded the change for review

Commit message

debug/pe: avoid panic in File.ImportedSymbols

This change skips symbols where dt.OriginalFirstThunk is less than
ds.VirtualAddress.

The variable types are uint32, and
(dt.OriginalFirstThunk-ds.VirtualAddress) becomes very large number when
dt.OriginalFirstThunk < ds.VirtualAddress.

Fixes #73548.
Change-Id: I72908bd0896003423aeb754fa0b6c72d452cdb4e

Change diff

diff --git a/src/debug/pe/file.go b/src/debug/pe/file.go
index ed63a11..8d78493 100644
--- a/src/debug/pe/file.go
+++ b/src/debug/pe/file.go
@@ -408,6 +408,9 @@
dt.dll, _ = getString(names, int(dt.Name-ds.VirtualAddress))
d, _ = ds.Data()
// seek to OriginalFirstThunk
+ if dt.OriginalFirstThunk < ds.VirtualAddress {
+ continue
+ }
d = d[dt.OriginalFirstThunk-ds.VirtualAddress:]
for len(d) > 0 {
if pe64 { // 64bit
diff --git a/src/debug/pe/file_test.go b/src/debug/pe/file_test.go
index 3d960ab..b1da0e9 100644
--- a/src/debug/pe/file_test.go
+++ b/src/debug/pe/file_test.go
@@ -688,50 +688,76 @@
}

func TestImportedSymbolsNoPanicWithSliceOutOfBound(t *testing.T) {
- // https://golang.org/issue/30253
- // ImportedSymbols shouldn't panic with slice out of bounds
- // Input generated by gofuzz
- data := []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@\x00" +
- "0\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@\x00" +
- "0\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\xc9" +
- "H\x895\x1d")
-
- f, err := NewFile(bytes.NewReader(data))
- if err != nil {
- t.Fatal(err)
+ tests := []struct {
+ name string
+ data []byte
+ }{
+ {
+ // https://golang.org/issue/30253
+ // ImportedSymbols shouldn't panic with slice out of bounds
+ // Input generated by gofuzz
+ name: "issue/30253",
+ data: []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@\x00" +
+ "0\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@\x00" +
+ "0\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\xc9" +
+ "H\x895\x1d"),
+ },
+ {
+ // https://golang.org/issue/73548
+ // ImportedSymbols shouldn't panic with slice out of bounds
+ // Input is provided on the issue https://github.com/golang/go/issues/73548#issue-3030856705
+ // in https://go.dev/play/p/K1_mQcc4Fbd
+ name: "issue/73548",
+ //data: nil,
+ data: func() []byte {
+ data, err := os.ReadFile("testdata/first_32k_of_winword_exe")
+ if err != nil {
+ t.Fatal(err)
+ }
+ return data
+ }(),
+ },
}
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ f, err := NewFile(bytes.NewReader(test.data))
+ if err != nil {
+ t.Fatal(err)
+ }

- syms, err := f.ImportedSymbols()
- if err != nil {
- t.Fatal(err)
- }
+ syms, err := f.ImportedSymbols()
+ if err != nil {
+ t.Fatal(err)
+ }

- if len(syms) != 0 {
- t.Fatalf("expected len(syms) == 0, received len(syms) = %d", len(syms))
+ if len(syms) != 0 {
+ t.Fatalf("expected len(syms) == 0, received len(syms) = %d", len(syms))
+ }
+ })
}
}
diff --git a/src/debug/pe/testdata/first_32k_of_winword_exe b/src/debug/pe/testdata/first_32k_of_winword_exe
new file mode 100644
index 0000000..4ae0255
--- /dev/null
+++ b/src/debug/pe/testdata/first_32k_of_winword_exe
Binary files differ

Change information

Files:
  • M src/debug/pe/file.go
  • M src/debug/pe/file_test.go
  • A src/debug/pe/testdata/first_32k_of_winword_exe
Change size: M
Delta: 3 files changed, 71 insertions(+), 42 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I72908bd0896003423aeb754fa0b6c72d452cdb4e
Gerrit-Change-Number: 684495
Gerrit-PatchSet: 1
Gerrit-Owner: Alex Brainman <alex.b...@gmail.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Alex Brainman (Gerrit)

unread,
Jun 27, 2025, 12:45:24 AMJun 27
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Alex Brainman voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I72908bd0896003423aeb754fa0b6c72d452cdb4e
Gerrit-Change-Number: 684495
Gerrit-PatchSet: 1
Gerrit-Owner: Alex Brainman <alex.b...@gmail.com>
Gerrit-Reviewer: Alex Brainman <alex.b...@gmail.com>
Gerrit-Comment-Date: Fri, 27 Jun 2025 04:45:15 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy

Alex Brainman (Gerrit)

unread,
Jun 27, 2025, 12:49:23 AMJun 27
to goph...@pubsubhelper.golang.org, Go LUCI, golang-co...@googlegroups.com

Alex Brainman added 1 comment

Patchset-level comments
File-level comment, Patchset 1 (Latest):
Alex Brainman . resolved

Not sure if it is OK to merge largish (32kb) binary file src/debug/pe/testdata/first_32k_of_winword_exe .

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I72908bd0896003423aeb754fa0b6c72d452cdb4e
Gerrit-Change-Number: 684495
Gerrit-PatchSet: 1
Gerrit-Owner: Alex Brainman <alex.b...@gmail.com>
Gerrit-Reviewer: Alex Brainman <alex.b...@gmail.com>
Gerrit-Comment-Date: Fri, 27 Jun 2025 04:49:15 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
unsatisfied_requirement
satisfied_requirement
open
diffy

Emmanuel Odeke (Gerrit)

unread,
Nov 27, 2025, 11:30:31 PMNov 27
to Alex Brainman, goph...@pubsubhelper.golang.org, Ian Lance Taylor, Go LUCI, golang-co...@googlegroups.com
Attention needed from Alex Brainman and Ian Lance Taylor

Emmanuel Odeke added 1 comment

Patchset-level comments
Emmanuel Odeke . resolved

Thank you Alex for this change and long time! Kindly please rebase from master and I am going to kindly tag Ian to help review.

Open in Gerrit

Related details

Attention is currently required from:
  • Alex Brainman
  • Ian Lance Taylor
Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I72908bd0896003423aeb754fa0b6c72d452cdb4e
    Gerrit-Change-Number: 684495
    Gerrit-PatchSet: 1
    Gerrit-Owner: Alex Brainman <alex.b...@gmail.com>
    Gerrit-Reviewer: Alex Brainman <alex.b...@gmail.com>
    Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
    Gerrit-CC: Emmanuel Odeke <emma...@orijtech.com>
    Gerrit-Attention: Ian Lance Taylor <ia...@golang.org>
    Gerrit-Attention: Alex Brainman <alex.b...@gmail.com>
    Gerrit-Comment-Date: Fri, 28 Nov 2025 04:30:27 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    Emmanuel Odeke (Gerrit)

    unread,
    Nov 28, 2025, 1:19:56 AMNov 28
    to Alex Brainman, goph...@pubsubhelper.golang.org, Ian Lance Taylor, Go LUCI, golang-co...@googlegroups.com
    Attention needed from Alex Brainman and Ian Lance Taylor

    Emmanuel Odeke added 2 comments

    Patchset-level comments
    Emmanuel Odeke . resolved

    Thank you for this fix Alex! I am including a suggestion for hardening against further crashes by tightening that check with `seek >= uint32(len(d))` given https://go.dev/play/p/jo0icuZyv1M. Kindly please update it.

    File src/debug/pe/file.go
    Line 411, Patchset 1 (Latest): if dt.OriginalFirstThunk < ds.VirtualAddress {
    continue
    }
    Emmanuel Odeke . unresolved

    I have a vector https://go.dev/play/p/jo0icuZyv1M that still crashes the line below and the correct check should be ensuring that we don't index with an overflown value so

    ```
    if seek := dt.OriginalFirstThunk - ds.VirtualAddress; seek >= uint32(len(d)) {
    continue
    } else {
    d = d[seek:]
    }
    ```
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Alex Brainman
    • Ian Lance Taylor
    Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: I72908bd0896003423aeb754fa0b6c72d452cdb4e
      Gerrit-Change-Number: 684495
      Gerrit-PatchSet: 1
      Gerrit-Owner: Alex Brainman <alex.b...@gmail.com>
      Gerrit-Reviewer: Alex Brainman <alex.b...@gmail.com>
      Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
      Gerrit-CC: Emmanuel Odeke <emma...@orijtech.com>
      Gerrit-Attention: Ian Lance Taylor <ia...@golang.org>
      Gerrit-Attention: Alex Brainman <alex.b...@gmail.com>
      Gerrit-Comment-Date: Fri, 28 Nov 2025 06:19:53 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy

      Alex Brainman (Gerrit)

      unread,
      Dec 15, 2025, 11:06:41 PM (16 hours ago) Dec 15
      to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
      Attention needed from Alex Brainman and Ian Lance Taylor

      Alex Brainman uploaded new patchset

      Alex Brainman uploaded patch set #2 to this change.
      Following approvals got outdated and were removed:
      • TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Alex Brainman
      • Ian Lance Taylor
      Submit Requirements:
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        • requirement is not satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: newpatchset
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I72908bd0896003423aeb754fa0b6c72d452cdb4e
        Gerrit-Change-Number: 684495
        Gerrit-PatchSet: 2
        unsatisfied_requirement
        open
        diffy

        Ian Lance Taylor (Gerrit)

        unread,
        Dec 15, 2025, 11:12:34 PM (15 hours ago) Dec 15
        to Alex Brainman, goph...@pubsubhelper.golang.org, Ian Lance Taylor, Emmanuel Odeke, Go LUCI, golang-co...@googlegroups.com
        Attention needed from Alex Brainman

        Ian Lance Taylor added 3 comments

        File src/debug/pe/file.go
        Line 416, Patchset 2 (Latest): continue
        Ian Lance Taylor . unresolved

        Why continue rather than returning an error?

        Line 417, Patchset 2 (Latest): } else {
        Ian Lance Taylor . unresolved

        You don't need an "else" here.

        File src/debug/pe/file_test.go
        Line 759, Patchset 2 (Latest): name: "issue/73548/extra",
        Ian Lance Taylor . unresolved

        Our current policy for debug/elf,debug/macho,debug/pe is to not bother adding a test case for invalid object files. There is a vast number of invalid object files and we don't need copies of all them. Instead, we rely on the fuzzer to find problems.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Alex Brainman
        Submit Requirements:
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        • requirement is not satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I72908bd0896003423aeb754fa0b6c72d452cdb4e
        Gerrit-Change-Number: 684495
        Gerrit-PatchSet: 2
        Gerrit-Owner: Alex Brainman <alex.b...@gmail.com>
        Gerrit-Reviewer: Alex Brainman <alex.b...@gmail.com>
        Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
        Gerrit-CC: Emmanuel Odeke <emma...@orijtech.com>
        Gerrit-Attention: Alex Brainman <alex.b...@gmail.com>
        Gerrit-Comment-Date: Tue, 16 Dec 2025 04:12:29 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        unsatisfied_requirement
        open
        diffy

        Alex Brainman (Gerrit)

        unread,
        Dec 15, 2025, 11:52:06 PM (15 hours ago) Dec 15
        to goph...@pubsubhelper.golang.org, Ian Lance Taylor, Emmanuel Odeke, Go LUCI, golang-co...@googlegroups.com
        Attention needed from Emmanuel Odeke and Ian Lance Taylor

        Alex Brainman voted and added 7 comments

        Votes added by Alex Brainman

        Commit-Queue+1

        7 comments

        Patchset-level comments
        File-level comment, Patchset 1:
        Emmanuel Odeke . resolved

        Thank you Alex for this change and long time! Kindly please rebase from master and I am going to kindly tag Ian to help review.

        Alex Brainman

        Rebased.

        Emmanuel Odeke . resolved

        Thank you for this fix Alex! I am including a suggestion for hardening against further crashes by tightening that check with `seek >= uint32(len(d))` given https://go.dev/play/p/jo0icuZyv1M. Kindly please update it.

        Alex Brainman

        Updated my CL.

        File-level comment, Patchset 2 (Latest):
        Alex Brainman . resolved

        Thank you Emmanuel and Ian for review.

        PTAL (hopefully TryBots will pass).

        Alex

        File src/debug/pe/file.go
        Line 411, Patchset 1: if dt.OriginalFirstThunk < ds.VirtualAddress {
        continue
        }
        Emmanuel Odeke . resolved

        I have a vector https://go.dev/play/p/jo0icuZyv1M that still crashes the line below and the correct check should be ensuring that we don't index with an overflown value so

        ```
        if seek := dt.OriginalFirstThunk - ds.VirtualAddress; seek >= uint32(len(d)) {
        continue
        } else {
        d = d[seek:]
        }
        ```
        Alex Brainman

        I used https://go.dev/play/p/jo0icuZyv1M in my adjusted CL.

        Ian Lance Taylor . unresolved

        Why continue rather than returning an error?

        Alex Brainman

        I do not understand how this code works. I never did.

        So I am trying to change the code as little as I can.

        But I will return error, if you insist.

        Ian Lance Taylor . unresolved

        You don't need an "else" here.

        Alex Brainman

        I do need that "else", otherwise I cannot use "seek" variable in
        ```
        d = d[seek:]
        ```
        on the next line.
        Let me know if you want me to rewrite that code.

        File src/debug/pe/file_test.go
        Line 759, Patchset 2 (Latest): name: "issue/73548/extra",
        Ian Lance Taylor . unresolved

        Our current policy for debug/elf,debug/macho,debug/pe is to not bother adding a test case for invalid object files. There is a vast number of invalid object files and we don't need copies of all them. Instead, we rely on the fuzzer to find problems.

        Alex Brainman

        What do you propose I do to stop people making this code panic again in the future?

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Emmanuel Odeke
        • Ian Lance Taylor
        Submit Requirements:
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        • requirement is not satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I72908bd0896003423aeb754fa0b6c72d452cdb4e
        Gerrit-Change-Number: 684495
        Gerrit-PatchSet: 2
        Gerrit-Owner: Alex Brainman <alex.b...@gmail.com>
        Gerrit-Reviewer: Alex Brainman <alex.b...@gmail.com>
        Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
        Gerrit-CC: Emmanuel Odeke <emma...@orijtech.com>
        Gerrit-Attention: Emmanuel Odeke <emma...@orijtech.com>
        Gerrit-Attention: Ian Lance Taylor <ia...@golang.org>
        Gerrit-Comment-Date: Tue, 16 Dec 2025 04:51:58 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        Comment-In-Reply-To: Emmanuel Odeke <emma...@orijtech.com>
        Comment-In-Reply-To: Ian Lance Taylor <ia...@golang.org>
        unsatisfied_requirement
        open
        diffy

        Ian Lance Taylor (Gerrit)

        unread,
        Dec 15, 2025, 11:59:53 PM (15 hours ago) Dec 15
        to Alex Brainman, goph...@pubsubhelper.golang.org, Ian Lance Taylor, Emmanuel Odeke, Go LUCI, golang-co...@googlegroups.com
        Attention needed from Alex Brainman and Emmanuel Odeke

        Ian Lance Taylor added 3 comments

        File src/debug/pe/file.go
        Ian Lance Taylor . unresolved

        Why continue rather than returning an error?

        Alex Brainman

        I do not understand how this code works. I never did.

        So I am trying to change the code as little as I can.

        But I will return error, if you insist.

        Ian Lance Taylor

        I'm not insisting. You should do what you think is best.

        It's just that it seems to me that if the seek value is too large, then something is wrong. The file is corrupt.

        Ian Lance Taylor . unresolved

        You don't need an "else" here.

        Alex Brainman

        I do need that "else", otherwise I cannot use "seek" variable in
        ```
        d = d[seek:]
        ```
        on the next line.
        Let me know if you want me to rewrite that code.

        Ian Lance Taylor

        Personally I would write it as

            seek := ...
        if seek >= uint32(len(d)) {
        return error
        }
        d = d[seek:]

        But you should write it as you see best.

        File src/debug/pe/file_test.go
        Line 759, Patchset 2 (Latest): name: "issue/73548/extra",
        Ian Lance Taylor . unresolved

        Our current policy for debug/elf,debug/macho,debug/pe is to not bother adding a test case for invalid object files. There is a vast number of invalid object files and we don't need copies of all them. Instead, we rely on the fuzzer to find problems.

        Alex Brainman

        What do you propose I do to stop people making this code panic again in the future?

        Ian Lance Taylor

        People run fuzzers on these packages. That will catch any errors introduced in the future. It doesn't scale for us to add every possible invalid file. There are too many.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Alex Brainman
        • Emmanuel Odeke
        Submit Requirements:
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        • requirement is not satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I72908bd0896003423aeb754fa0b6c72d452cdb4e
        Gerrit-Change-Number: 684495
        Gerrit-PatchSet: 2
        Gerrit-Owner: Alex Brainman <alex.b...@gmail.com>
        Gerrit-Reviewer: Alex Brainman <alex.b...@gmail.com>
        Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
        Gerrit-CC: Emmanuel Odeke <emma...@orijtech.com>
        Gerrit-Attention: Emmanuel Odeke <emma...@orijtech.com>
        Gerrit-Attention: Alex Brainman <alex.b...@gmail.com>
        Gerrit-Comment-Date: Tue, 16 Dec 2025 04:59:49 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Ian Lance Taylor <ia...@golang.org>
        Comment-In-Reply-To: Alex Brainman <alex.b...@gmail.com>
        unsatisfied_requirement
        open
        diffy

        Emmanuel Odeke (Gerrit)

        unread,
        12:04 AM (15 hours ago) 12:04 AM
        to Alex Brainman, goph...@pubsubhelper.golang.org, Ian Lance Taylor, Go LUCI, golang-co...@googlegroups.com
        Attention needed from Alex Brainman

        Emmanuel Odeke added 3 comments

        Patchset-level comments
        File-level comment, Patchset 2 (Latest):
        Emmanuel Odeke . resolved

        Thank you Alex for the fixes! Thank you Ian for the code review. Alex, I agree with the insights from Ian's review and kindly ask that we apply them, then LGTM.

        File src/debug/pe/file.go
        Ian Lance Taylor . unresolved

        Why continue rather than returning an error?

        Alex Brainman

        I do not understand how this code works. I never did.

        So I am trying to change the code as little as I can.

        But I will return error, if you insist.

        Ian Lance Taylor

        I'm not insisting. You should do what you think is best.

        It's just that it seems to me that if the seek value is too large, then something is wrong. The file is corrupt.

        Emmanuel Odeke

        Yeah I agree with Ian's insight about this being a corrupted file and think too that perhaps we should return an error.

        Ian Lance Taylor . unresolved

        You don't need an "else" here.

        Alex Brainman

        I do need that "else", otherwise I cannot use "seek" variable in
        ```
        d = d[seek:]
        ```
        on the next line.
        Let me know if you want me to rewrite that code.

        Ian Lance Taylor

        Personally I would write it as

            seek := ...
        if seek >= uint32(len(d)) {
        return error
        }
        d = d[seek:]

        But you should write it as you see best.

        Emmanuel Odeke

        Sure, @alex.b...@gmail.com the composite statement and check has become long
        so perhaps let's make that break. Thank you, Ian!

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Alex Brainman
        Submit Requirements:
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        • requirement is not satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I72908bd0896003423aeb754fa0b6c72d452cdb4e
        Gerrit-Change-Number: 684495
        Gerrit-PatchSet: 2
        Gerrit-Owner: Alex Brainman <alex.b...@gmail.com>
        Gerrit-Reviewer: Alex Brainman <alex.b...@gmail.com>
        Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
        Gerrit-CC: Emmanuel Odeke <emma...@orijtech.com>
        Gerrit-Attention: Alex Brainman <alex.b...@gmail.com>
        Gerrit-Comment-Date: Tue, 16 Dec 2025 05:03:59 +0000
        unsatisfied_requirement
        open
        diffy
        Reply all
        Reply to author
        Forward
        0 new messages