Panic when a static route destination is an empty string
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 2.2k
- Forks
- 875
- PR merge metrics
- No merged PRs in 30d
Description
2019-06-06 14:12:21.432660 I | http: panic serving @: runtime error: invalid memory address or nil pointer dereference
goroutine 724 [running]:
net/http.(*conn).serve.func1(0xc420d81860)
/usr/local/go/src/net/http/server.go:1726 +0xd2
panic(0x55806a76b060, 0x55806b64c240)
/usr/local/go/src/runtime/panic.go:502 +0x22d
net.networkNumberAndMask(0x0, 0x0, 0x0, 0xc4218b8ea8, 0x5580695c094a, 0xc421084b00, 0xc420998db0)
/usr/local/go/src/net/ip.go:445 +0x28
net.(*IPNet).String(0x0, 0xc420c252f0, 0x55806aabd2c0)
/usr/local/go/src/net/ip.go:495 +0x42
github.com/docker/docker/vendor/github.com/docker/libnetwork.(*sandbox).populateNetworkResources(0xc420714900, 0xc420dd5600, 0xc4218b9360, 0xc420714900)
/go/src/github.com/docker/docker/vendor/github.com/docker/libnetwork/sandbox.go:885 +0x20b
github.com/docker/docker/vendor/github.com/docker/libnetwork.(*endpoint).sbJoin(0xc420dd4840, 0xc420714900, 0x0, 0x0, 0x0, 0x0, 0x0)
/go/src/github.com/docker/docker/vendor/github.com/docker/libnetwork/endpoint.go:523 +0x6df
github.com/docker/docker/vendor/github.com/docker/libnetwork.(*endpoint).Join(0xc420dd4840, 0x55806aaf1140, 0xc420714900, 0x0, 0x0, 0x0, 0x0, 0x0)
/go/src/github.com/docker/docker/vendor/github.com/docker/libnetwork/endpoint.go:442 +0xc1
github.com/docker/docker/daemon.(*Daemon).connectToNetwork(0xc4208ce1e0, 0xc420ce1b00, 0xc420db88af, 0x40, 0xc4206d72c0, 0x558068898d01, 0x0, 0x0)
/go/src/github.com/docker/docker/daemon/container_operations.go:782 +0x699
github.com/docker/docker/daemon.(*Daemon).ConnectToNetwork(0xc4208ce1e0, 0xc420ce1b00, 0xc420db88af, 0x40, 0xc4206d72c0, 0x0, 0x0)
/go/src/github.com/docker/docker/daemon/container_operations.go:1046 +0x2b3
github.com/docker/docker/daemon.(*Daemon).ConnectContainerToNetwork(0xc4208ce1e0, 0xc421119a80, 0x40, 0xc420db88af, 0x40, 0xc4206d72c0, 0x2, 0x7d00000000000001)
/go/src/github.com/docker/docker/daemon/network.go:450 +0xa1
github.com/docker/docker/api/server/router/network.(*networkRouter).postNetworkConnect(0xc42090ca00, 0x55806aadaee0, 0xc420e2f290, 0x55806aad92e0, 0xc420cbee00, 0xc420175f00, 0xc420e2efc0, 0x558069e5d7cc, 0x5)
/go/src/github.com/docker/docker/api/server/router/network/network_routes.go:278 +0x330
github.com/docker/docker/api/server/router/network.(*networkRouter).(github.com/docker/docker/api/server/router/network.postNetworkConnect)-fm(0x55806aadaee0, 0xc420e2f290, 0x55806aad92e0, 0xc420cbee00, 0xc420175f00, 0xc420e2efc0, 0x5580689c59dc, 0x55806a919ec0)
/go/src/github.com/docker/docker/api/server/router/network/network.go:37 +0x6b
github.com/docker/docker/api/server/middleware.ExperimentalMiddleware.WrapHandler.func1(0x55806aadaee0, 0xc420e2f290, 0x55806aad92e0, 0xc420cbee00, 0xc420175f00, 0xc420e2efc0, 0x55806aadaee0, 0xc420e2f290)
/go/src/github.com/docker/docker/api/server/middleware/experimental.go:26 +0xda
github.com/docker/docker/api/server/middleware.VersionMiddleware.WrapHandler.func1(0x55806aadaee0, 0xc420e2f020, 0x55806aad92e0, 0xc420cbee00, 0xc420175f00, 0xc420e2efc0, 0x0, 0x0)
/go/src/github.com/docker/docker/api/server/middleware/version.go:62 +0x401
github.com/docker/docker/pkg/authorization.(*Middleware).WrapHandler.func1(0x55806aadaee0, 0xc420e2f020, 0x55806aad92e0, 0xc420cbee00, 0xc420175f00, 0xc420e2efc0, 0x0, 0x55806a02d868)
/go/src/github.com/docker/docker/pkg/authorization/middleware.go:59 +0x7ab
github.com/docker/docker/api/server/middleware.DebugRequestMiddleware.func1(0x55806aadaee0, 0xc420e2f020, 0x55806aad92e0, 0xc420cbee00, 0xc420175f00, 0xc420e2efc0, 0x55806aadaee0, 0xc420e2f020)
/go/src/github.com/docker/docker/api/server/middleware/debug.go:53 +0x4b8
github.com/docker/docker/api/server.(*Server).makeHTTPHandler.func1(0x55806aad92e0, 0xc420cbee00, 0xc420175f00)
/go/src/github.com/docker/docker/api/server/server.go:141 +0x19a
net/http.HandlerFunc.ServeHTTP(0xc4215225a0, 0x55806aad92e0, 0xc420cbee00, 0xc420175f00)
/usr/local/go/src/net/http/server.go:1947 +0x46
github.com/docker/docker/vendor/github.com/gorilla/mux.(*Router).ServeHTTP(0xc42148b090, 0x55806aad92e0, 0xc420cbee00, 0xc420175f00)
/go/src/github.com/docker/docker/vendor/github.com/gorilla/mux/mux.go:103 +0x228
github.com/docker/docker/api/server.(*routerSwapper).ServeHTTP(0xc421466070, 0x55806aad92e0, 0xc420cbee00, 0xc420175f00)
/go/src/github.com/docker/docker/api/server/router_swapper.go:29 +0x72
net/http.serverHandler.ServeHTTP(0xc4207e9790, 0x55806aad92e0, 0xc420cbee00, 0xc420175f00)
/usr/local/go/src/net/http/server.go:2697 +0xbe
net/http.(*conn).serve(0xc420d81860, 0x55806aadae20, 0xc4206b6b80)
/usr/local/go/src/net/http/server.go:1830 +0x653
created by net/http.(*Server).Serve
/usr/local/go/src/net/http/server.go:2798 +0x27d
I was sending an empty string in Destination from a plugin's /NetworkDriver.Join route.
Setting it to another invalid value doesn't panic and reports correctly on the error
https://github.com/docker/libnetwork/blob/ce86291472a965c5cd6adaf2c83acaee6bab630a/sandbox.go#L885
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at vendor/github.com/docker/libnetwork/sandbox.go around line 885, where the empty Destination from the plugin's /NetworkDriver.Join route reaches network resource population. Reproduce the case with an empty destination, compare it with another invalid value, and confirm that the empty value is handled as an error without panicking.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100