Gerrit Bot has uploaded this change for review.
net: Check length of input ip address before for loop
Change-Id: I04c962272f24e95c6bfcec0c70fa5a32b7f482c7
GitHub-Last-Rev: f69dff4ac673cff649a3526076f97f9733995705
GitHub-Pull-Request: golang/go#55987
---
M src/net/ip.go
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/src/net/ip.go b/src/net/ip.go
index 54c5288..604fe67 100644
--- a/src/net/ip.go
+++ b/src/net/ip.go
@@ -562,11 +562,11 @@
// Parse IPv4 address (d.d.d.d).
func parseIPv4(s string) IP {
var p [IPv4len]byte
+ if len(s) == 0 {
+ // Missing octets.
+ return nil
+ }
for i := 0; i < IPv4len; i++ {
- if len(s) == 0 {
- // Missing octets.
- return nil
- }
if i > 0 {
if s[0] != '.' {
return nil
@@ -719,6 +719,9 @@
// parseIPZone parses s as an IP address, return it and its associated zone
// identifier (IPv6 only).
func parseIPZone(s string) (IP, string) {
+ if len(s) == 0 {
+ return nil, ""
+ }
for i := 0; i < len(s); i++ {
switch s[i] {
case '.':
To view, visit change 437515. To unsubscribe, or for help writing mail filters, visit settings.
Congratulations on opening your first change. Thank you for your contribution!
Next steps:
A maintainer will review your change and provide feedback. See
https://go.dev/doc/contribute#review for more info and tips to get your
patch through code review.
Most changes in the Go project go through a few rounds of revision. This can be
surprising to people new to the project. The careful, iterative review process
is our way of helping mentor contributors and ensuring that their contributions
have a lasting impact.
During May-July and Nov-Jan the Go project is in a code freeze, during which
little code gets reviewed or merged. If a reviewer responds with a comment like
R=go1.11 or adds a tag like "wait-release", it means that this CL will be
reviewed as part of the next development cycle. See https://go.dev/s/release
for more details.
Attention is currently required from: Damien Neil, Ian Lance Taylor.
Gerrit Bot uploaded patch set #2 to this change.
net: Check length of input ip address before for loop
It would be good if length of the given string is checked before for loop and return appropriate return value.
Change-Id: I04c962272f24e95c6bfcec0c70fa5a32b7f482c7
GitHub-Last-Rev: f69dff4ac673cff649a3526076f97f9733995705
GitHub-Pull-Request: golang/go#55987
---
M src/net/ip.go
1 file changed, 20 insertions(+), 4 deletions(-)
To view, visit change 437515. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Damien Neil.
1 comment:
File src/net/ip.go:
Patch Set #2, Line 565: if len(s) == 0 {
The variable s is changed during the loop. This patch changes the behavior of the coffee.
To view, visit change 437515. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Damien Neil.
Gerrit Bot uploaded patch set #3 to this change.
net: Check length of input ip address before for loop
It would be good if length of the given string is checked before for loop and return appropriate return value.
Change-Id: I04c962272f24e95c6bfcec0c70fa5a32b7f482c7
GitHub-Last-Rev: 6a844376f6ab28538f33ab91dcd124496d3ab77b
GitHub-Pull-Request: golang/go#55987
---
M src/net/ip.go
1 file changed, 19 insertions(+), 0 deletions(-)
To view, visit change 437515. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Ian Lance Taylor.
Gerrit Bot uploaded patch set #4 to this change.
net: check length of input ip address before for loop
It would be good if length of the given string is checked before for loop and return appropriate return value.
Change-Id: I04c962272f24e95c6bfcec0c70fa5a32b7f482c7
GitHub-Last-Rev: 6a844376f6ab28538f33ab91dcd124496d3ab77b
GitHub-Pull-Request: golang/go#55987
---
M src/net/ip.go
1 file changed, 19 insertions(+), 0 deletions(-)
To view, visit change 437515. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Ian Lance Taylor.
1 comment:
File src/net/ip.go:
Patch Set #2, Line 565: if len(s) == 0 {
The variable s is changed during the loop. This patch changes the behavior of the coffee.
Ack, added len check in the beginning and unchanged the loop logic, Pls review
To view, visit change 437515. To unsubscribe, or for help writing mail filters, visit settings.
1 comment:
Patchset:
Thanks, but I don't see any reason to do this. It's very unlikely that anybody will call these functions with an empty string, and it seems to me that if they do the right thing will happen. There's no reason to add an extra check for an unlikely case.
To view, visit change 437515. To unsubscribe, or for help writing mail filters, visit settings.
Gerrit Bot uploaded patch set #5 to this change.
net: check length of input ip address before for loop
It would be good if length of the given string is checked before for loop and return appropriate return value.
Change-Id: I04c962272f24e95c6bfcec0c70fa5a32b7f482c7
GitHub-Last-Rev: 8f6a4f0b4ccfeb0e2d3ed498e257caef96092237
GitHub-Pull-Request: golang/go#55987
---
M src/net/ip.go
1 file changed, 19 insertions(+), 0 deletions(-)
To view, visit change 437515. To unsubscribe, or for help writing mail filters, visit settings.
Gopher Robot abandoned this change.
To view, visit change 437515. To unsubscribe, or for help writing mail filters, visit settings.