]> Cypherpunks repositories - gostls13.git/commitdiff
net: report port number correctly in Plan 9 error
authorIan Lance Taylor <iant@golang.org>
Thu, 27 Feb 2020 15:36:39 +0000 (07:36 -0800)
committerIan Lance Taylor <iant@golang.org>
Fri, 28 Feb 2020 16:22:42 +0000 (16:22 +0000)
The code was incorrectly using a string conversion of a numeric port
to display the port number.

No test because as far as I can tell this code is only executed if
there is some error in a /net file.

Updates #32479

Change-Id: I0b8deebbf3c0b7cb1e1eee0fd059505f3f4c1623
Reviewed-on: https://go-review.googlesource.com/c/go/+/221377
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/net/ipsock_plan9.go

index 93f0f4eec36cf0c3b5358ef4779db2973ac7501d..eaf306495550dbebb77f171ebb1ea63dd5f6ee7e 100644 (file)
@@ -57,12 +57,12 @@ func parsePlan9Addr(s string) (ip IP, iport int, err error) {
                        return nil, 0, &ParseError{Type: "IP address", Text: s}
                }
        }
-       p, _, ok := dtoi(s[i+1:])
+       p, plen, ok := dtoi(s[i+1:])
        if !ok {
                return nil, 0, &ParseError{Type: "port", Text: s}
        }
        if p < 0 || p > 0xFFFF {
-               return nil, 0, &AddrError{Err: "invalid port", Addr: string(p)}
+               return nil, 0, &AddrError{Err: "invalid port", Addr: s[i+1 : i+1+plen]}
        }
        return addr, p, nil
 }