summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-09-15 06:23:00 -0400
committerGitHub <noreply@github.com>2021-09-15 06:23:00 -0400
commit10873c6f494fbc7a43365000f6f9702c21741077 (patch)
tree8eb5e73ac7144c4918d95c31a9b0b68746038b53 /pkg
parentaff64dda65514064ccbf7fcaf78293e111539eb6 (diff)
parent9b04e17893dbf91326c0f68ce7627d7bb07cf515 (diff)
downloadpodman-10873c6f494fbc7a43365000f6f9702c21741077.tar.gz
podman-10873c6f494fbc7a43365000f6f9702c21741077.tar.bz2
podman-10873c6f494fbc7a43365000f6f9702c21741077.zip
Merge pull request #11578 from jelly/handle_nil_pointer_deref
api: handle nil pointer dereference in api endpoints
Diffstat (limited to 'pkg')
-rw-r--r--pkg/api/handlers/compat/containers.go6
-rw-r--r--pkg/api/handlers/libpod/containers.go7
-rw-r--r--pkg/api/handlers/libpod/images.go8
3 files changed, 18 insertions, 3 deletions
diff --git a/pkg/api/handlers/compat/containers.go b/pkg/api/handlers/compat/containers.go
index 26e1bf00b..a15fdb553 100644
--- a/pkg/api/handlers/compat/containers.go
+++ b/pkg/api/handlers/compat/containers.go
@@ -104,8 +104,12 @@ func ListContainers(w http.ResponseWriter, r *http.Request) {
}
filterMap, err := util.PrepareFilters(r)
+ if err != nil {
+ utils.Error(w, "Something went wrong.", 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, "Something went wrong.", http.StatusInternalServerError, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
diff --git a/pkg/api/handlers/libpod/containers.go b/pkg/api/handlers/libpod/containers.go
index 4639093f2..343c0d0b3 100644
--- a/pkg/api/handlers/libpod/containers.go
+++ b/pkg/api/handlers/libpod/containers.go
@@ -73,8 +73,13 @@ func ListContainers(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()))
return
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()))