aboutsummaryrefslogtreecommitdiff
path: root/src/net/lookup.go
diff options
context:
space:
mode:
authorMorten Siebuhr <sbhr@sbhr.dk>2016-02-19 21:53:17 +0100
committerMikio Hara <mikioh.mikioh@gmail.com>2016-04-15 23:11:47 +0000
commit002c69e05d6a24693ac1052d98845ec635f34c19 (patch)
tree7c2485abe3f199994d08d9f40e3c7ac0ba0a5a34 /src/net/lookup.go
parentb6b4004d5a5bf7099ac9ab76777797236da7fe63 (diff)
downloadgo-002c69e05d6a24693ac1052d98845ec635f34c19.tar.gz
go-002c69e05d6a24693ac1052d98845ec635f34c19.zip
net: fix looking up port numbers starting with numbers.
LookupPort() correctly parses service names beginning with numerals by implementing a new parser, mainly taken from strconv/atoi.go. Also testes some previously undefined behaviours around port numbers larger than 65535 that previously could lead to some tests fail with EOPNOTSUPP (Operation Not Supported). Fixes #14322 Change-Id: I1b90dbed434494723e261d84e73fe705e5c0507a Reviewed-on: https://go-review.googlesource.com/19720 Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
Diffstat (limited to 'src/net/lookup.go')
-rw-r--r--src/net/lookup.go9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/net/lookup.go b/src/net/lookup.go
index 0d3ef79bab..8f02787422 100644
--- a/src/net/lookup.go
+++ b/src/net/lookup.go
@@ -112,13 +112,8 @@ func lookupIPContext(ctx context.Context, host string) (addrs []IPAddr, err erro
// LookupPort looks up the port for the given network and service.
func LookupPort(network, service string) (port int, err error) {
- if service == "" {
- // Lock in the legacy behavior that an empty string
- // means port 0. See Issue 13610.
- return 0, nil
- }
- port, _, ok := dtoi(service, 0)
- if !ok && port != big && port != -big {
+ port, needsLookup := parsePort(service)
+ if needsLookup {
port, err = lookupPort(network, service)
if err != nil {
return 0, err