Fix crash when remote plugin returns empty address string
If a remote plugin returns an empty string in response to RequestAddress(), the internal helper will return nil which will crash libnetwork in several places. Treat an empty string as a new error ipamapi.ErrNoIPReturned. Signed-off-by: Thomas Graf <tgraf@suug.ch>
This commit is contained in:
parent
e42fca1872
commit
7acedb94f3
2 changed files with 3 additions and 0 deletions
|
@ -46,6 +46,7 @@ var (
|
|||
ErrOverlapPool = types.ForbiddenErrorf("Address pool overlaps with existing pool on this address space")
|
||||
ErrNoAvailablePool = types.NoServiceErrorf("No available pool")
|
||||
ErrNoAvailableIPs = types.NoServiceErrorf("No available addresses on this pool")
|
||||
ErrNoIPReturned = types.NoServiceErrorf("No address returned")
|
||||
ErrIPAlreadyAllocated = types.ForbiddenErrorf("Address already in use")
|
||||
ErrIPOutOfRange = types.BadRequestErrorf("Requested address is out of range")
|
||||
ErrPoolOverlap = types.ForbiddenErrorf("Pool overlaps with other one on this address space")
|
||||
|
|
|
@ -111,6 +111,8 @@ func (a *allocator) RequestAddress(poolID string, address net.IP, options map[st
|
|||
}
|
||||
if res.Address != "" {
|
||||
retAddress, err = types.ParseCIDR(res.Address)
|
||||
} else {
|
||||
return nil, nil, ipamapi.ErrNoIPReturned
|
||||
}
|
||||
return retAddress, res.Data, err
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue