From 9f5bbecb9507690875694c646b2f0ea725c1e595 Mon Sep 17 00:00:00 2001 From: Tigran Sogomonian Date: Thu, 7 Nov 2024 14:53:15 +0300 Subject: [PATCH] api: Add error check Add error check during tmpfile close. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Tigran Sogomonian --- pkg/api/handlers/libpod/images.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/api/handlers/libpod/images.go b/pkg/api/handlers/libpod/images.go index 6b5e5abb31..3e35a0dbb4 100644 --- a/pkg/api/handlers/libpod/images.go +++ b/pkg/api/handlers/libpod/images.go @@ -410,7 +410,10 @@ func ImagesImport(w http.ResponseWriter, r *http.Request) { return } - tmpfile.Close() + if err := tmpfile.Close(); err != nil { + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("unable to close tempfile: %w", err)) + return + } source = tmpfile.Name() }