Merge pull request #89870 from gaurav1086/controller_nil_ptr_check

[Controller]: cidr nil ptr dereference
This commit is contained in:
Kubernetes Prow Robot 2020-04-14 14:02:17 -07:00 committed by GitHub
commit 344130a574
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -158,15 +158,14 @@ func (s *CidrSet) AllocateNext() (*net.IPNet, error) {
}
func (s *CidrSet) getBeginingAndEndIndices(cidr *net.IPNet) (begin, end int, err error) {
if cidr == nil {
return -1, -1, fmt.Errorf("error getting indices for cluster cidr %v, cidr is nil", s.clusterCIDR)
}
begin, end = 0, s.maxCIDRs-1
cidrMask := cidr.Mask
maskSize, _ := cidrMask.Size()
var ipSize int
if cidr == nil {
return -1, -1, fmt.Errorf("error getting indices for cluster cidr %v, cidr is nil", s.clusterCIDR)
}
if !s.clusterCIDR.Contains(cidr.IP.Mask(s.clusterCIDR.Mask)) && !cidr.Contains(s.clusterCIDR.IP.Mask(cidr.Mask)) {
return -1, -1, fmt.Errorf("cidr %v is out the range of cluster cidr %v", cidr, s.clusterCIDR)
}