mirror of
https://github.com/containers/podman.git
synced 2026-10-23 02:15:11 -04: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:
1 parent
f1775a34ab
commit
dee94ea699
2 files changed
+7
No files matched your search
@@ -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