Blame SOURCES/reject-leading-zeros.patch

012508
diff --git a/doc/go1.15.html b/doc/go1.15.html
012508
index c9997c0..c2315f1 100644
012508
--- a/doc/go1.15.html
012508
+++ b/doc/go1.15.html
012508
@@ -795,6 +795,15 @@ Do not send CLs removing the interior tags from such phrases.
012508
       The new Resolver.LookupIP
012508
       method supports IP lookups that are both network-specific and accept a context.
012508
     

012508
+
012508
+    

012508
+      The ParseIP and ParseCIDR
012508
+      functions now reject IPv4 addresses which contain decimal components with leading zeros.
012508
+      These components were always interpreted as decimal, but some operating systems treat them as octal.
012508
+      This mismatch could hypothetically lead to security issues if a Go application was used to validate IP addresses
012508
+      which were then used in their original form with non-Go applications which interpreted components as octal. Generally,
012508
+      it is advisable to always re-encoded values after validation, which avoids this class of parser misalignment issues.
012508
+    

012508
   
012508
 
012508
 
012508
diff --git a/src/net/hosts_test.go b/src/net/hosts_test.go
012508
index f850e2f..19c4399 100644
012508
--- a/src/net/hosts_test.go
012508
+++ b/src/net/hosts_test.go
012508
@@ -36,7 +36,7 @@ var lookupStaticHostTests = []struct {
012508
 		},
012508
 	},
012508
 	{
012508
-		"testdata/ipv4-hosts", // see golang.org/issue/8996
012508
+		"testdata/ipv4-hosts",
012508
 		[]staticHostEntry{
012508
 			{"localhost", []string{"127.0.0.1", "127.0.0.2", "127.0.0.3"}},
012508
 			{"localhost.localdomain", []string{"127.0.0.3"}},
012508
@@ -102,7 +102,7 @@ var lookupStaticAddrTests = []struct {
012508
 		},
012508
 	},
012508
 	{
012508
-		"testdata/ipv4-hosts", // see golang.org/issue/8996
012508
+		"testdata/ipv4-hosts",
012508
 		[]staticHostEntry{
012508
 			{"127.0.0.1", []string{"localhost"}},
012508
 			{"127.0.0.2", []string{"localhost"}},
012508
diff --git a/src/net/ip.go b/src/net/ip.go
012508
index c00fe8e..007f3f7 100644
012508
--- a/src/net/ip.go
012508
+++ b/src/net/ip.go
012508
@@ -552,6 +552,10 @@ func parseIPv4(s string) IP {
012508
 		if !ok || n > 0xFF {
012508
 			return nil
012508
 		}
012508
+		if c > 1 && s[0] == '0' {
012508
+			// Reject non-zero components with leading zeroes.
012508
+			return nil
012508
+		}
012508
 		s = s[c:]
012508
 		p[i] = byte(n)
012508
 	}
012508
diff --git a/src/net/ip_test.go b/src/net/ip_test.go
012508
index a5fc5e6..585381d 100644
012508
--- a/src/net/ip_test.go
012508
+++ b/src/net/ip_test.go
012508
@@ -20,9 +20,7 @@ var parseIPTests = []struct {
012508
 }{
012508
 	{"127.0.1.2", IPv4(127, 0, 1, 2)},
012508
 	{"127.0.0.1", IPv4(127, 0, 0, 1)},
012508
-	{"127.001.002.003", IPv4(127, 1, 2, 3)},
012508
 	{"::ffff:127.1.2.3", IPv4(127, 1, 2, 3)},
012508
-	{"::ffff:127.001.002.003", IPv4(127, 1, 2, 3)},
012508
 	{"::ffff:7f01:0203", IPv4(127, 1, 2, 3)},
012508
 	{"0:0:0:0:0000:ffff:127.1.2.3", IPv4(127, 1, 2, 3)},
012508
 	{"0:0:0:0:000000:ffff:127.1.2.3", IPv4(127, 1, 2, 3)},
012508
@@ -42,6 +40,11 @@ var parseIPTests = []struct {
012508
 	{"fe80::1%911", nil},
012508
 	{"", nil},
012508
 	{"a1:a2:a3:a4::b1:b2:b3:b4", nil}, // Issue 6628
012508
+	{"127.001.002.003", nil},
012508
+	{"::ffff:127.001.002.003", nil},
012508
+	{"123.000.000.000", nil},
012508
+	{"1.2..4", nil},
012508
+	{"0123.0.0.1", nil},
012508
 }
012508
 
012508
 func TestParseIP(t *testing.T) {
012508
@@ -357,6 +360,7 @@ var parseCIDRTests = []struct {
012508
 	{"0.0.-2.0/32", nil, nil, &ParseError{Type: "CIDR address", Text: "0.0.-2.0/32"}},
012508
 	{"0.0.0.-3/32", nil, nil, &ParseError{Type: "CIDR address", Text: "0.0.0.-3/32"}},
012508
 	{"0.0.0.0/-0", nil, nil, &ParseError{Type: "CIDR address", Text: "0.0.0.0/-0"}},
012508
+	{"127.000.000.001/32", nil, nil, &ParseError{Type: "CIDR address", Text: "127.000.000.001/32"}},
012508
 	{"", nil, nil, &ParseError{Type: "CIDR address", Text: ""}},
012508
 }
012508
 
012508
diff --git a/src/net/testdata/ipv4-hosts b/src/net/testdata/ipv4-hosts
012508
index 5208bb4..6b99675 100644
012508
--- a/src/net/testdata/ipv4-hosts
012508
+++ b/src/net/testdata/ipv4-hosts
012508
@@ -1,12 +1,8 @@
012508
 # See https://tools.ietf.org/html/rfc1123.
012508
-#
012508
-# The literal IPv4 address parser in the net package is a relaxed
012508
-# one. It may accept a literal IPv4 address in dotted-decimal notation
012508
-# with leading zeros such as "001.2.003.4".
012508
 
012508
 # internet address and host name
012508
 127.0.0.1	localhost	# inline comment separated by tab
012508
-127.000.000.002	localhost       # inline comment separated by space
012508
+127.0.0.2	localhost   # inline comment separated by space
012508
 
012508
 # internet address, host name and aliases
012508
-127.000.000.003	localhost	localhost.localdomain
012508
+127.0.0.3	localhost	localhost.localdomain