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

Bug report: bad NextIP of "0.0.0.1" #783

Closed
mars1024 opened this issue Nov 17, 2022 · 2 comments
Closed

Bug report: bad NextIP of "0.0.0.1" #783

mars1024 opened this issue Nov 17, 2022 · 2 comments

Comments

@mars1024
Copy link
Member

When I use

plugins/pkg/ip/cidr.go

Lines 23 to 26 in 7e9ada5

func NextIP(ip net.IP) net.IP {
i := ipToInt(ip)
return intToIP(i.Add(i, big.NewInt(1)))
}
to get next IP of address "0.0.0.1", I got an illegal result [2] but not an expected one [0,0,0,2].

This is because intToIP does not obey the byte length of IPv4(4)/IPv6(16) when first byte is 0.

plugins/pkg/ip/cidr.go

Lines 51 to 53 in 7e9ada5

func intToIP(i *big.Int) net.IP {
return net.IP(i.Bytes())
}

This bug will happen when first byte is 0 no matter family is IPv4 or IPv6.

@mmorel-35
Copy link
Contributor

Fixed by #782

@mars1024
Copy link
Member Author

/close

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

No branches or pull requests

2 participants