From b2d0b92db2f1263bf9a27cc34434e4fe911ff3ab Mon Sep 17 00:00:00 2001 From: Garth Bushell Date: Thu, 21 Mar 2024 14:49:03 +0000 Subject: [PATCH] Dont save remote context in temp file but stream and extract Signed-off-by: Garth Bushell --- pkg/api/handlers/compat/images_build.go | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go index 7d2cc37a9b..eb2a227823 100644 --- a/pkg/api/handlers/compat/images_build.go +++ b/pkg/api/handlers/compat/images_build.go @@ -891,26 +891,12 @@ func parseLibPodIsolation(isolation string) (buildah.Isolation, error) { } func extractTarFile(anchorDir string, r *http.Request) (string, error) { - path := filepath.Join(anchorDir, "tarBall") - tarBall, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o600) - if err != nil { - return "", err - } - defer tarBall.Close() - - // Content-Length not used as too many existing API clients didn't honor it - _, err = io.Copy(tarBall, r.Body) - if err != nil { - return "", fmt.Errorf("failed Request: Unable to copy tar file from request body %s", r.RequestURI) - } - buildDir := filepath.Join(anchorDir, "build") - err = os.Mkdir(buildDir, 0o700) + err := os.Mkdir(buildDir, 0o700) if err != nil { return "", err } - _, _ = tarBall.Seek(0, 0) - err = archive.Untar(tarBall, buildDir, nil) + err = archive.Untar(r.Body, buildDir, nil) return buildDir, err }