]> Cypherpunks repositories - gostls13.git/commitdiff
net: fix ParseIP
authorQuan Yong Zhai <qyzhai@gmail.com>
Fri, 15 Apr 2011 03:49:51 +0000 (23:49 -0400)
committerRuss Cox <rsc@golang.org>
Fri, 15 Apr 2011 03:49:51 +0000 (23:49 -0400)
Fixes #1695.

R=golang-dev, rsc
CC=golang-dev, r
https://golang.org/cl/4418042

src/pkg/net/ip.go
src/pkg/net/ip_test.go

index 12bb6f351a1e914a4f76faecf37cc98c9afdf307..2429b10d9b354a3128c4acc6581bdf7de2f524fd 100644 (file)
@@ -436,7 +436,7 @@ func parseIPv6(s string) IP {
                }
 
                // Otherwise must be followed by colon and more.
-               if s[i] != ':' && i+1 == len(s) {
+               if s[i] != ':' || i+1 == len(s) {
                        return nil
                }
                i++
index f1a4716d227b4bc200af719f0fa8a0c77833c806..2008953ef3822df9bf1212f695f2170ddbcdd58a 100644 (file)
@@ -29,6 +29,7 @@ var parseiptests = []struct {
        {"127.0.0.1", IPv4(127, 0, 0, 1)},
        {"127.0.0.256", nil},
        {"abc", nil},
+       {"123:", nil},
        {"::ffff:127.0.0.1", IPv4(127, 0, 0, 1)},
        {"2001:4860:0:2001::68",
                IP{0x20, 0x01, 0x48, 0x60, 0, 0, 0x20, 0x01,