1
0
mirror of https://github.com/golang/go synced 2024-11-21 20:04:44 -07:00

net: fix ParseIP

Fixes #1695.

R=golang-dev, rsc
CC=golang-dev, r
https://golang.org/cl/4418042
This commit is contained in:
Quan Yong Zhai 2011-04-14 23:49:51 -04:00 committed by Russ Cox
parent 24bb0340b6
commit c09af6631f
2 changed files with 2 additions and 1 deletions

View 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++

View 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,