From 789223f2dc6f92553311f22523bb53abf7936039 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sun, 1 May 2022 19:55:36 +0200 Subject: [PATCH] api: postContainersStop, postContainersRestart remove redundant validation Both of these pass the signal to daemon.containerStop(), which already validates the signal; https://github.com/moby/moby/blob/2ed904cad7055847796433cc56ef1d1de0da868c/daemon/stop.go#L48-L52 Signed-off-by: Sebastiaan van Stijn --- api/server/router/container/container_routes.go | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/api/server/router/container/container_routes.go b/api/server/router/container/container_routes.go index cfa6838772..55005d5278 100644 --- a/api/server/router/container/container_routes.go +++ b/api/server/router/container/container_routes.go @@ -226,12 +226,7 @@ func (s *containerRouter) postContainersStop(ctx context.Context, w http.Respons version = httputils.VersionFromContext(ctx) ) if versions.GreaterThanOrEqualTo(version, "1.42") { - if sig := r.Form.Get("signal"); sig != "" { - if _, err := signal.ParseSignal(sig); err != nil { - return errdefs.InvalidParameter(err) - } - options.Signal = sig - } + options.Signal = r.Form.Get("signal") } if tmpSeconds := r.Form.Get("t"); tmpSeconds != "" { valSeconds, err := strconv.Atoi(tmpSeconds) @@ -294,12 +289,7 @@ func (s *containerRouter) postContainersRestart(ctx context.Context, w http.Resp version = httputils.VersionFromContext(ctx) ) if versions.GreaterThanOrEqualTo(version, "1.42") { - if sig := r.Form.Get("signal"); sig != "" { - if _, err := signal.ParseSignal(sig); err != nil { - return errdefs.InvalidParameter(err) - } - options.Signal = sig - } + options.Signal = r.Form.Get("signal") } if tmpSeconds := r.Form.Get("t"); tmpSeconds != "" { valSeconds, err := strconv.Atoi(tmpSeconds)