buildkitd: fix index-out-of-range panic in parsing wrong addr string

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
docker-18.09
Akihiro Suda 2018-01-23 11:29:07 +09:00
parent ff49ce87a6
commit 51e22a478a
1 changed files with 4 additions and 0 deletions

View File

@ -214,6 +214,10 @@ func serveGRPC(server *grpc.Server, addrs []string, errCh chan error) error {
func getListener(addr string) (net.Listener, error) {
addrSlice := strings.SplitN(addr, "://", 2)
if len(addrSlice) < 2 {
return nil, errors.Errorf("address %s does not contain proto, you meant unix://%s ?",
addr, addr)
}
proto := addrSlice[0]
listenAddr := addrSlice[1]
switch proto {