Skip to content

Commit a76c0f8

Browse files
author
Josh Powers
committed
modfetch: prevent duplicate hashes in go.sum
To write go.sum, each module and then each hash is looped through. The hashes are kept in a slice and there is no check to ensure that hashes were not added or already exist in the file. This uniques the hashes of each module before writting to prevent duplicates. Fixes: #28456
1 parent 346698e commit a76c0f8

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/cmd/go/internal/modfetch/fetch.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"cmd/go/internal/lockedfile"
2727
"cmd/go/internal/par"
2828
"cmd/go/internal/robustio"
29+
"cmd/go/internal/str"
2930
"cmd/go/internal/trace"
3031

3132
"golang.org/x/mod/module"
@@ -832,6 +833,7 @@ Outer:
832833
for _, m := range mods {
833834
list := goSum.m[m]
834835
sort.Strings(list)
836+
str.Uniq(&list)
835837
for _, h := range list {
836838
st := goSum.status[modSum{m, h}]
837839
if (!st.dirty || (st.used && keep[m])) && !sumInWorkspaceModulesLocked(m) {

0 commit comments

Comments
 (0)