From 6f124eba7d5283f650488f9f462e1b3a0f19e413 Mon Sep 17 00:00:00 2001 From: Michael Schurter Date: Fri, 8 Dec 2017 12:27:57 -0800 Subject: [PATCH] Be more defensive in port checks --- command/agent/consul/client.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/command/agent/consul/client.go b/command/agent/consul/client.go index a26befa31..93e001acb 100644 --- a/command/agent/consul/client.go +++ b/command/agent/consul/client.go @@ -1112,7 +1112,7 @@ func getAddress(addrMode, portLabel string, networks structs.Networks, driverNet case structs.AddressModeHost: // Default path: use host ip:port ip, port := networks.Port(portLabel) - if ip == "" && port == 0 { + if ip == "" && port <= 0 { return "", 0, fmt.Errorf("invalid port %q: port label not found", portLabel) } return ip, port, nil @@ -1133,7 +1133,7 @@ func getAddress(addrMode, portLabel string, networks structs.Networks, driverNet if err != nil { return "", 0, fmt.Errorf("invalid port %q: %v", portLabel, err) } - if port == 0 { + if port <= 0 { return "", 0, fmt.Errorf("invalid port: %q: port 0 is invalid", portLabel) }