]> Cypherpunks.ru repositories - gostls13.git/commitdiff
debug/macho: don't use narch for seenArches map size
authorIan Lance Taylor <iant@golang.org>
Tue, 23 Aug 2022 00:37:07 +0000 (17:37 -0700)
committerGopher Robot <gobot@golang.org>
Tue, 23 Aug 2022 20:31:52 +0000 (20:31 +0000)
If narch is very large we would allocate a lot of memory for seenArches.
In practice we aren't going to see many different architectures so
don't bother to specify a size for the seenArches map.

No debug/macho test case because the problem can only happen for
invalid data. Let the fuzzer find cases like this.

For #47653
For #52523

Change-Id: I5a3b0e3aa6172ddffd6f44d9ae513c39a00d8764
Reviewed-on: https://go-review.googlesource.com/c/go/+/425114
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
src/debug/macho/fat.go

index 775beaf12ce43319f47e5c0f397dd0479343c47f..7dc03fa79a33dc01df500ca2c475490ec42edb92 100644 (file)
@@ -80,7 +80,7 @@ func NewFatFile(r io.ReaderAt) (*FatFile, error) {
 
        // Combine the Cpu and SubCpu (both uint32) into a uint64 to make sure
        // there are not duplicate architectures.
-       seenArches := make(map[uint64]bool, narch)
+       seenArches := make(map[uint64]bool)
        // Make sure that all images are for the same MH_ type.
        var machoType Type