From aaa9f4ea9022576250b75349dd908613d5e3378a Mon Sep 17 00:00:00 2001 From: Brent Baude Date: Tue, 4 Oct 2022 15:12:27 -0500 Subject: 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 --- pkg/api/handlers/compat/images.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pkg') 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) -- cgit v1.2.3-54-g00ecf