Skip to content

Commit

Permalink
Merge pull request moby#17703 from aboch/np
Browse files Browse the repository at this point in the history
Verify Endpoint.Info() before accessing it
  • Loading branch information
cpuguy83 committed Nov 5, 2015
2 parents 1ef3b1f + 54d22cb commit f18c5e9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
13 changes: 11 additions & 2 deletions api/server/router/network/network_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,11 @@ func buildNetworkResource(nw libnetwork.Network) *types.NetworkResource {

epl := nw.Endpoints()
for _, e := range epl {
sb := e.Info().Sandbox()
ei := e.Info()
if ei == nil {
continue
}
sb := ei.Sandbox()
if sb == nil {
continue
}
Expand Down Expand Up @@ -233,7 +237,12 @@ func buildEndpointResource(e libnetwork.Endpoint) types.EndpointResource {
}

er.EndpointID = e.ID()
if iface := e.Info().Iface(); iface != nil {
ei := e.Info()
if ei == nil {
return er
}

if iface := ei.Iface(); iface != nil {
if mac := iface.MacAddress(); mac != nil {
er.MacAddress = mac.String()
}
Expand Down
6 changes: 5 additions & 1 deletion daemon/container_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,11 @@ func (container *Container) disconnectFromNetwork(n libnetwork.Network) error {
)

s := func(current libnetwork.Endpoint) bool {
if sb := current.Info().Sandbox(); sb != nil {
epInfo := current.Info()
if epInfo == nil {
return false
}
if sb := epInfo.Sandbox(); sb != nil {
if sb.ContainerID() == container.ID {
ep = current
sbox = sb
Expand Down

0 comments on commit f18c5e9

Please sign in to comment.