Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
[proxy] Handle null HostConfigs gracefully in start
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfonso Acosta authored and rade committed Oct 1, 2015
1 parent 725f99e commit c24dc66
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion proxy/start_container_interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (i *startContainerInterceptor) InterceptRequest(r *http.Request) error {
}

hostConfig := &docker.HostConfig{}
if err := unmarshalRequestBody(r, &hostConfig); err != nil {
if err := unmarshalRequestBody(r, hostConfig); err != nil {
return err
}

Expand Down
4 changes: 4 additions & 0 deletions test/666_abuse_of_start_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ proxy docker_on $HOST1 create --name=c3 -v /tmp:/hosttmp $SMALL_IMAGE $CHECK_ETH
proxy docker_api_on $HOST1 POST /containers/c3/start '{"Binds":[],"Dns":null,"DnsSearch":null,"ExtraHosts":null,"VolumesFrom":null,"Devices":null,"NetworkMode":""}'
assert "docker_on $HOST1 inspect -f '{{.State.Running}} {{.State.ExitCode}} {{.HostConfig.Dns}}' c3" "false 0 [$docker_bridge_ip]"

# Start c4 with an 'null' HostConfig
proxy docker_on $HOST1 create --name=c4 $SMALL_IMAGE echo foo
assert_raises "proxy docker_api_on $HOST1 POST /containers/c4/start 'null'"

end_suite
2 changes: 1 addition & 1 deletion test/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ docker_api_on() {
data=$4
shift 4
[ -z "$DEBUG" ] || greyly echo "Docker (API) on $host:$DOCKER_PORT: $method $url" >&2
echo -n "$data" | curl -s -X "$method" -H Content-Type:application/json "http://$host:$DOCKER_PORT/v1.15$url" -d @-
echo -n "$data" | curl -s -f -X "$method" -H Content-Type:application/json "http://$host:$DOCKER_PORT/v1.15$url" -d @-
}

proxy() {
Expand Down

0 comments on commit c24dc66

Please sign in to comment.