1
0
mirror of https://github.com/docker/cli.git synced 2026-01-15 07:40:57 +03:00

Make volumes opts more strict

Upstream-commit: c7661f40b6c6a23e5fe2090a94bd9fa6521242d7
Component: engine
This commit is contained in:
Guillaume J. Charmes
2013-11-26 23:00:44 +00:00
parent 8e6cdb74dc
commit f70d58d92d

View File

@@ -1666,8 +1666,11 @@ func (opts PathOpts) String() string { return fmt.Sprintf("%v", map[string]struc
func (opts PathOpts) Set(val string) error {
var containerPath string
splited := strings.SplitN(val, ":", 2)
if len(splited) == 1 {
if strings.Count(val, ":") > 2 {
return fmt.Errorf("bad format for volumes: %s", val)
}
if splited := strings.SplitN(val, ":", 2); len(splited) == 1 {
containerPath = splited[0]
val = filepath.Clean(splited[0])
} else {
@@ -1680,6 +1683,7 @@ func (opts PathOpts) Set(val string) error {
return fmt.Errorf("%s is not an absolute path", containerPath)
}
opts[val] = struct{}{}
return nil
}