aboutsummaryrefslogtreecommitdiff
path: root/pkg/api
diff options
context:
space:
mode:
authorBrent Baude <bbaude@redhat.com>2022-10-04 15:12:27 -0500
committerBrent Baude <bbaude@redhat.com>2022-10-04 15:31:00 -0500
commitaaa9f4ea9022576250b75349dd908613d5e3378a (patch)
treea8f94c3b05acb7b246fc076bfe856adbcd7fa67c /pkg/api
parent0330d1abed7559e33baf50167a161e8ec54363b3 (diff)
downloadpodman-aaa9f4ea9022576250b75349dd908613d5e3378a.tar.gz
podman-aaa9f4ea9022576250b75349dd908613d5e3378a.tar.bz2
podman-aaa9f4ea9022576250b75349dd908613d5e3378a.zip
Prevent nil pointer deref in GetImage
Trying to print the image id on a failed inspect will result in a nil pointer panic because the image will be nil. Replace image.id with the image name which is defined as a string without the use of inspect. Fixes: bz#2131836 [NO NEW TESTS NEEDED] Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/api')
-rw-r--r--pkg/api/handlers/compat/images.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/pkg/api/handlers/compat/images.go b/pkg/api/handlers/compat/images.go
index cce482441..d61df5232 100644
--- a/pkg/api/handlers/compat/images.go
+++ b/pkg/api/handlers/compat/images.go
@@ -403,7 +403,7 @@ func GetImage(w http.ResponseWriter, r *http.Request) {
}
inspect, err := handlers.ImageDataToImageInspect(r.Context(), newImage)
if err != nil {
- utils.Error(w, http.StatusInternalServerError, fmt.Errorf("failed to convert ImageData to ImageInspect '%s': %w", inspect.ID, err))
+ utils.Error(w, http.StatusInternalServerError, fmt.Errorf("failed to convert ImageData to ImageInspect '%s': %w", name, err))
return
}
utils.WriteResponse(w, http.StatusOK, inspect)