diff --git a/proxy/start_container_interceptor.go b/proxy/start_container_interceptor.go index 678fbacf..cec672dc 100644 --- a/proxy/start_container_interceptor.go +++ b/proxy/start_container_interceptor.go @@ -15,7 +15,7 @@ func (i *startContainerInterceptor) InterceptRequest(r *http.Request) error { // If the client has sent some JSON which might be a HostConfig, add our // parameters back into it, otherwise Docker will consider them overwritten - if containerShouldAttach(container) && r.Header.Get("Content-Type") == "application/json" { + if containerShouldAttach(container) && r.Header.Get("Content-Type") == "application/json" && r.ContentLength > 0 { params := map[string]interface{}{} if err := unmarshalRequestBody(r, ¶ms); err != nil { return err diff --git a/test/666_abuse_of_start_test.sh b/test/666_abuse_of_start_test.sh index 2f666bc0..183c8f60 100755 --- a/test/666_abuse_of_start_test.sh +++ b/test/666_abuse_of_start_test.sh @@ -33,6 +33,11 @@ proxy docker_on $HOST1 create --name=c4 --memory-swap -1 $SMALL_IMAGE echo foo assert_raises "proxy docker_api_on $HOST1 POST /containers/c4/start 'null'" assert "docker_on $HOST1 inspect -f '{{.HostConfig.MemorySwap}}' c4" "-1" +# Start c4b with an empty HostConfig (generated by Docker 1.11.0-rc2) +proxy docker_on $HOST1 create --name=c4b --memory-swap -1 $SMALL_IMAGE echo foo +assert_raises "proxy docker_api_on $HOST1 POST /containers/c4b/start ''" +assert "docker_on $HOST1 inspect -f '{{.HostConfig.MemorySwap}}' c4b" "-1" + # Start c6 with both named and unnamed HostConfig proxy docker_on $HOST1 create --name=c6 $SMALL_IMAGE $CHECK_ETHWE_UP proxy docker_api_on $HOST1 POST /containers/c6/start '{"NetworkMode": "container:c2", "HostConfig": {"NetworkMode": "container:c1"}}'