From 2e0c92b1685e337c7032b326c56bf3934e852f82 Mon Sep 17 00:00:00 2001 From: Stephen J Day Date: Fri, 24 Feb 2017 18:31:26 -0800 Subject: [PATCH] cmd/dist/fetch: address subtle concurrency bug When using the fetcher concurrently, the loop modifying the closed `base` parameter was causing urls from different digests to be returned randomly. We copy the the value and then modify it to make it work correctly. Luckily, we are using content addressable storage or this would have been undetectable. Signed-off-by: Stephen J Day --- cmd/dist/fetch.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/dist/fetch.go b/cmd/dist/fetch.go index 0488948..1bb5570 100644 --- a/cmd/dist/fetch.go +++ b/cmd/dist/fetch.go @@ -139,11 +139,11 @@ func getResolver(ctx contextpkg.Context) (remotes.Resolver, error) { } for _, path := range paths { - base.Path = path - url := base.String() + url := base + url.Path = path log.G(ctx).WithField("url", url).Debug("fetch content") - req, err := http.NewRequest(http.MethodGet, url, nil) + req, err := http.NewRequest(http.MethodGet, url.String(), nil) if err != nil { return nil, err }