Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: IP.{IsLinkLocalUnicast,IsLinkLocalMulticast,IsGlobalUnicast} false positives #11585

Closed
thockin opened this issue Jul 4, 2015 · 5 comments
Milestone

Comments

@thockin
Copy link

thockin commented Jul 4, 2015

I found this inspecting the code to understand the test.

http://play.golang.org/p/gXdT4o45uw

It looks like those methods are assuming that any IP they get is a 16 byte slice, but as far as I know a 4 byte slice is a valid IP.

@thockin
Copy link
Author

thockin commented Jul 4, 2015

Also panic()s if you pass an empty slice (e.g. net.ParseIP("garbage").IsLinkLocalUnicast())

@mikioh mikioh changed the title stdlib: net.ip.IsLinkLocalUnicast() and .IsLinkLocalMulticast() false positives net: IP.IsLinkLocalUnicast() and .IsLinkLocalMulticast() false positives Jul 4, 2015
@mikioh mikioh added this to the Go1.5 milestone Jul 4, 2015
@mikioh
Copy link
Contributor

mikioh commented Jul 4, 2015

It's intentional; don't call any methods on a nil value of net.IP.

@gopherbot
Copy link

CL https://golang.org/cl/11883 mentions this issue.

@thockin
Copy link
Author

thockin commented Jul 4, 2015

Thanks for the fix, looks clean to me.
On Jul 3, 2015 9:59 PM, "Mikio Hara" notifications@github.com wrote:

It's intentional; don't call any methods on a nil value of net.IP.


Reply to this email directly or view it on GitHub
#11585 (comment).

@mikioh mikioh changed the title net: IP.IsLinkLocalUnicast() and .IsLinkLocalMulticast() false positives net: IP.{IsLinkLocalUnicast,IsLinkLocalMulticast,IsGlobalUnicast} false positives Jul 7, 2015
@mikioh
Copy link
Contributor

mikioh commented Jul 7, 2015

Also IsGlobalUnicast(net.ParseIP("255.255.255.255")).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants