plugins icon indicating copy to clipboard operation
plugins copied to clipboard

Bug report: bad NextIP of "0.0.0.1"

Open mars1024 opened this issue 2 years ago • 0 comments

When I use https://github.com/containernetworking/plugins/blob/7e9ada51e751740541969e1ea5a803cbf45adcf3/pkg/ip/cidr.go#L23-L26 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. https://github.com/containernetworking/plugins/blob/7e9ada51e751740541969e1ea5a803cbf45adcf3/pkg/ip/cidr.go#L51-L53

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

mars1024 avatar Nov 17 '22 12:11 mars1024