summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/libpod/images.go
diff options
context:
space:
mode:
authorJelle van der Waa <jvanderwaa@redhat.com>2021-09-14 22:23:01 +0200
committerJelle van der Waa <jvanderwaa@redhat.com>2021-09-15 09:14:34 +0200
commit9b04e17893dbf91326c0f68ce7627d7bb07cf515 (patch)
treed63dd1378a675d81945c628502e88f8faf866912 /pkg/api/handlers/libpod/images.go
parent323fe363134ba81ed33c24d7cce85aa0c37ab59d (diff)
downloadpodman-9b04e17893dbf91326c0f68ce7627d7bb07cf515.tar.gz
podman-9b04e17893dbf91326c0f68ce7627d7bb07cf515.tar.bz2
podman-9b04e17893dbf91326c0f68ce7627d7bb07cf515.zip
api: handle nil pointer dereference in rest endpoints
When `?all=garbage` is passed to an API endpoint schema validation fails and err is nil. Wrapf uses err to create an error message causing a nil pointer dereference. Signed-off-by: Jelle van der Waa <jvanderwaa@redhat.com>
Diffstat (limited to 'pkg/api/handlers/libpod/images.go')
-rw-r--r--pkg/api/handlers/libpod/images.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/pkg/api/handlers/libpod/images.go b/pkg/api/handlers/libpod/images.go
index 72093c492..b4f08a746 100644
--- a/pkg/api/handlers/libpod/images.go
+++ b/pkg/api/handlers/libpod/images.go
@@ -156,8 +156,14 @@ func PruneImages(w http.ResponseWriter, r *http.Request) {
}
filterMap, err := util.PrepareFilters(r)
+ if err != nil {
+ utils.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError,
+ errors.
+ Wrapf(err, "failed to decode filter parameters for %s", r.URL.String()))
+ return
+ }
- if dErr := decoder.Decode(&query, r.URL.Query()); dErr != nil || err != nil {
+ if err := decoder.Decode(&query, r.URL.Query()); err != nil {
utils.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError,
errors.
Wrapf(err, "failed to parse parameters for %s", r.URL.String()))