Fixes an issue in cide_set.go

Function getBeginingAndEndIndices may return
end index too big
pull/6/head
Robert Pothier 2017-04-17 11:08:19 -04:00
parent 190a0cab89
commit bde909c55b
2 changed files with 3 additions and 3 deletions

View File

@ -79,7 +79,7 @@ func (s *cidrSet) allocateNext() (*net.IPNet, error) {
}
func (s *cidrSet) getBeginingAndEndIndices(cidr *net.IPNet) (begin, end int, err error) {
begin, end = 0, s.maxCIDRs
begin, end = 0, s.maxCIDRs-1
cidrMask := cidr.Mask
maskSize, _ := cidrMask.Size()

View File

@ -249,7 +249,7 @@ func TestOccupy(t *testing.T) {
subNetMaskSize: 16,
subNetCIDRStr: "127.0.0.0/8",
expectedUsedBegin: 0,
expectedUsedEnd: 256,
expectedUsedEnd: 255,
expectErr: false,
},
{
@ -257,7 +257,7 @@ func TestOccupy(t *testing.T) {
subNetMaskSize: 16,
subNetCIDRStr: "127.0.0.0/2",
expectedUsedBegin: 0,
expectedUsedEnd: 256,
expectedUsedEnd: 255,
expectErr: false,
},
{