Possible IP comparison issue due to multiple possible representations
- Dominant language
- Go
- Stars
- 6.1k
- Forks
- 609
- Avg merge
- 15h 1m
- Merged PRs (30d)
- 3
Description
The code at https://github.com/hashicorp/serf/blob/master/cmd/serf/command/agent/ipc_event_stream_test.go#L110 makes the assumption that IPv4 addresses are always stored in a 4 byte long byte slice and similarly a IPv6 address is stored as a 16 byte slice.
This assumption however does not hold, as the net.IP's state (https://golang.org/pkg/net/#IP):
> Note that in this documentation, referring to an IP address as an IPv4 address or an IPv6 address is a semantic property of the address, not just the length of the byte slice: a **16-byte slice can still be an IPv4 address.**
Due to this byte slice based comparisons of IP addresses may not be always as meaningful as the user might expect, and the same IPv4 with different internal representation my cause comparison mismatches, resulting in unforseen anomalies.
*Note, this issue report was not initiated by my use of this package and noticing a bug, rather by creating an extension proposal for `go vet` and that signalling the possible misuse in this library.*
Cheers :)
PS: No, this is not an automatically opened issue, I do do this manually to make sure it's not something irrelevant.
Contributor guide
Assessment
This issue has not been assessed yet.