github-vet / github-vet/rangeloop-pointer-findings
cloudfoundry-incubator/fissile: docker/docker.go; 39 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [cloudfoundry-incubator/fissile](https://www.github.com/cloudfoundry-incubator/fissile) at [docker/docker.go](https://github.com/cloudfoundry-incubator/fissile/blob/b8e8e6af42ef32efc5387f6a69312feacc78e96c/docker/docker.go#L616-L654)
Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first
issue it finds, so please do not limit your consideration to the contents of the below message.
> range-loop variable src used in defer or goroutine at line 623
[Click here to see the code in its original context.](https://github.com/cloudfoundry-incubator/fissile/blob/b8e8e6af42ef32efc5387f6a69312feacc78e96c/docker/docker.go#L616-L654)
Click here to show the 39 line(s) of Go which triggered the analyzer.
```go
for src, dest := range opts.StreamOut {
tarStream := tarstream.New(fsWithSymlinks)
r, w := io.Pipe()
go func() {
err := d.client.DownloadFromContainer(container.ID, dockerclient.DownloadFromContainerOptions{
OutputStream: w,
Path: src,
})
if err != nil {
w.CloseWithError(err)
}
w.Close()
}()
err := tarStream.ExtractTarStream(dest, r)
if err != nil {
return err
}
// Docker will include the directory in the output tar stream so
// we need to move things arround
sourceDirectoryName := filepath.Base(src)
streamedOutputDir := filepath.Join(dest, sourceDirectoryName)
tmpDestDir := filepath.Join(filepath.Dir(dest), fmt.Sprintf("%s-tmp", filepath.Base(dest)))
err = os.Rename(streamedOutputDir, tmpDestDir)
if err != nil {
return err
}
err = os.RemoveAll(dest)
if err != nil {
return err
}
err = os.Rename(tmpDestDir, dest)
if err != nil {
return err
}
}
```
Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.
commit ID: b8e8e6af42ef32efc5387f6a69312feacc78e96c
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.