mirror of
https://github.com/moby/moby.git
synced 2025-07-30 18:23:29 +03:00
Docker http panics caused by container deletion with empty names.
This fix tries to fix the http panics caused by container deletion with empty names in #22210. The issue was because when an empty string was passed, `GetByName()` tried to access the first element of the name string without checking the length. A length check has been added. A test case for #22210 has been added. This fix fixes #22210. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
@ -1616,3 +1616,11 @@ func (s *DockerSuite) TestPostContainersCreateWithOomScoreAdjInvalidRange(c *che
|
||||
c.Fatalf("Expected output to contain %q, got %q", expected, string(b))
|
||||
}
|
||||
}
|
||||
|
||||
// test case for #22210 where an emtpy container name caused panic.
|
||||
func (s *DockerSuite) TestContainerApiDeleteWithEmptyName(c *check.C) {
|
||||
status, out, err := sockRequest("DELETE", "/containers/", nil)
|
||||
c.Assert(err, checker.IsNil)
|
||||
c.Assert(status, checker.Equals, http.StatusBadRequest)
|
||||
c.Assert(string(out), checker.Contains, "No container name or ID supplied")
|
||||
}
|
||||
|
Reference in New Issue
Block a user