]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/buildid: reject rewriting legacy buildids
authorStephen Eckels <stevemk14ebr@gmail.com>
Sat, 4 Jun 2022 20:39:36 +0000 (20:39 +0000)
committerGopher Robot <gobot@golang.org>
Mon, 6 Jun 2022 14:30:53 +0000 (14:30 +0000)
This resolves legacy go binaries crashing the buildid tool when the -w flag is specified.

Fixes #50809

Change-Id: I55a866f285a3c2cebcf2cdbb9cc30e5078e1d18f
GitHub-Last-Rev: 7169a58fd7ba17fdeb8037cef3f50080169dc137
GitHub-Pull-Request: golang/go#53163
Reviewed-on: https://go-review.googlesource.com/c/go/+/409535
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
src/cmd/buildid/buildid.go

index 8e02a7ae109611488417ab480cd47288de45d81a..72ad80dbbba02f094aaac43d1e924c5fdf9b39f9 100644 (file)
@@ -53,6 +53,11 @@ func main() {
                log.Fatal(err)
        }
 
+       // <= go 1.7 doesn't embed the contentID or actionID, so no slash is present
+       if !strings.Contains(id, "/") {
+               log.Fatalf("%s: build ID is a legacy format...binary too old for this tool", file)
+       }
+
        newID := id[:strings.LastIndex(id, "/")] + "/" + buildid.HashToString(hash)
        if len(newID) != len(id) {
                log.Fatalf("%s: build ID length mismatch %q vs %q", file, id, newID)