mirror of
https://github.com/containers/podman.git
synced 2025-07-02 08:47:43 +08:00
bugfix: do not try to parse empty ranges
An empty range caused a panic as parseOptionIDs tried to check further down for an @ at index 0 without taking into account that the splitted out string could be empty. Signed-off-by: Simon Brakhane <simon@brakhane.net>
This commit is contained in:
@ -65,6 +65,10 @@ func parseOptionIDs(ctrMappings []idtools.IDMap, option string) ([]idtools.IDMap
|
||||
for i, m := range ranges {
|
||||
var v idtools.IDMap
|
||||
|
||||
if m == "" {
|
||||
return nil, fmt.Errorf("invalid empty range for %q", option)
|
||||
}
|
||||
|
||||
relative := false
|
||||
if m[0] == '@' {
|
||||
relative = true
|
||||
|
@ -70,6 +70,9 @@ func TestParseOptionIDs(t *testing.T) {
|
||||
|
||||
_, err = parseOptionIDs(idMap, "@10000-20000-2")
|
||||
assert.NotNil(t, err)
|
||||
|
||||
_, err = parseOptionIDs(idMap, "100-200-3###400-500-6")
|
||||
assert.NotNil(t, err)
|
||||
}
|
||||
|
||||
func TestParseIDMapMountOption(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user