From c7661f40b6c6a23e5fe2090a94bd9fa6521242d7 Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Tue, 26 Nov 2013 23:00:44 +0000 Subject: [PATCH] Make volumes opts more strict --- commands.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/commands.go b/commands.go index d992db2e6c..db752447f0 100644 --- a/commands.go +++ b/commands.go @@ -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 }