summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-06-01 18:00:56 +0200
committerGitHub <noreply@github.com>2020-06-01 18:00:56 +0200
commitf559cec6c0d1694cca9530004aaba3c138f621e3 (patch)
treef2a100cbe7bedfc0485c71cfd33892bfc70f490b
parent2c6016f330b2738d2545f7d353244dfc8b239050 (diff)
parent8c1883721c28d09c5c3629db7e0d77344f5f7bd9 (diff)
downloadpodman-f559cec6c0d1694cca9530004aaba3c138f621e3.tar.gz
podman-f559cec6c0d1694cca9530004aaba3c138f621e3.tar.bz2
podman-f559cec6c0d1694cca9530004aaba3c138f621e3.zip
Merge pull request #6447 from baude/v2apitarleak
Fix leak of empty tarball
-rw-r--r--pkg/api/handlers/libpod/images.go13
-rw-r--r--test/e2e/images_test.go2
2 files changed, 7 insertions, 8 deletions
diff --git a/pkg/api/handlers/libpod/images.go b/pkg/api/handlers/libpod/images.go
index 4b277d39c..54e202103 100644
--- a/pkg/api/handlers/libpod/images.go
+++ b/pkg/api/handlers/libpod/images.go
@@ -181,6 +181,12 @@ func ExportImage(w http.ResponseWriter, r *http.Request) {
errors.Wrapf(err, "Failed to parse parameters for %s", r.URL.String()))
return
}
+ name := utils.GetName(r)
+ newImage, err := runtime.ImageRuntime().NewFromLocal(name)
+ if err != nil {
+ utils.ImageNotFound(w, name, err)
+ return
+ }
switch query.Format {
case define.OCIArchive, define.V2s2Archive:
tmpfile, err := ioutil.TempFile("", "api.tar")
@@ -204,13 +210,6 @@ func ExportImage(w http.ResponseWriter, r *http.Request) {
utils.Error(w, "unknown format", http.StatusInternalServerError, errors.Errorf("unknown format %q", query.Format))
return
}
- name := utils.GetName(r)
- newImage, err := runtime.ImageRuntime().NewFromLocal(name)
- if err != nil {
- utils.ImageNotFound(w, name, err)
- return
- }
-
if err := newImage.Save(r.Context(), name, query.Format, output, []string{}, false, query.Compress); err != nil {
utils.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest, err)
return
diff --git a/test/e2e/images_test.go b/test/e2e/images_test.go
index 1b23aba36..9a073cde6 100644
--- a/test/e2e/images_test.go
+++ b/test/e2e/images_test.go
@@ -179,7 +179,7 @@ var _ = Describe("Podman images", func() {
It("podman images filter before image", func() {
SkipIfRemote()
dockerfile := `FROM docker.io/library/alpine:latest
-RUN apk update && apk add man
+RUN apk update && apk add strace
`
podmanTest.BuildImage(dockerfile, "foobar.com/before:latest", "false")
result := podmanTest.Podman([]string{"images", "-q", "-f", "before=foobar.com/before:latest"})