mirror of
https://github.com/moby/moby.git
synced 2026-08-08 17:11:38 +00:00
libnet/i/defaultipam: improve address pools validation
Nothing was validating whether address pools' `base` prefix were larger than the target subnet `size` they're associated to. As such invalid address pools would yield no subnet, the error could go unnoticed. Signed-off-by: Albin Kerouanton <albinker@gmail.com>
This commit is contained in:
@@ -95,6 +95,9 @@ func splitByIPFamily(s []*ipamutils.NetworkToSplit) ([]*ipamutils.NetworkToSplit
|
||||
if !n.Base.IsValid() || n.Size == 0 {
|
||||
return []*ipamutils.NetworkToSplit{}, []*ipamutils.NetworkToSplit{}, fmt.Errorf("network at index %d (%v) is not in canonical form", i, n)
|
||||
}
|
||||
if n.Base.Bits() > n.Size {
|
||||
return []*ipamutils.NetworkToSplit{}, []*ipamutils.NetworkToSplit{}, fmt.Errorf("network at index %d (%v) has a smaller prefix (/%d) than the target size of that pool (/%d)", i, n, n.Base.Bits(), n.Size)
|
||||
}
|
||||
|
||||
n.Base, _ = n.Base.Addr().Unmap().Prefix(n.Base.Bits())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user