]> Cypherpunks repositories - gostls13.git/commitdiff
net: ParseIP should return nil if :: doesn't expand in an IPv6 address.
authorAlex A Skinner <alex@lx.lc>
Fri, 20 Dec 2013 12:29:28 +0000 (21:29 +0900)
committerMikio Hara <mikioh.mikioh@gmail.com>
Fri, 20 Dec 2013 12:29:28 +0000 (21:29 +0900)
Per RFC 4291, 'The use of "::" indicates one or more groups of 16 bits of zeros.'
Fixes #6628

R=golang-dev, rsc, minux.ma, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/15990043

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

index fd6a7d4ee8bae274ea51f1d5892d07b82a6a25e9..0582009b8bdb58169dff74f5e5131fee0075364f 100644 (file)
@@ -623,6 +623,9 @@ func parseIPv6(s string, zoneAllowed bool) (ip IP, zone string) {
                for k := ellipsis + n - 1; k >= ellipsis; k-- {
                        ip[k] = 0
                }
+       } else if ellipsis >= 0 {
+               // Ellipsis must represent at least one 0 group.
+               return nil, zone
        }
        return ip, zone
 }
index 26b53729b85d8576c40296b8f3c9d8f567cc4014..ffeb9d315e703936f0f5c8b43e2579d9e431a4ba 100644 (file)
@@ -25,6 +25,7 @@ var parseIPTests = []struct {
        {"fe80::1%lo0", nil},
        {"fe80::1%911", nil},
        {"", nil},
+       {"a1:a2:a3:a4::b1:b2:b3:b4", nil}, // Issue 6628
 }
 
 func TestParseIP(t *testing.T) {