Browse code

Merge pull request #15846 from ZJU-SEL/11646-fix-path-validations

fix 11646 to check volume path in server side

Tibor Vass authored on 2015/09/04 09:42:37
Showing 3 changed files
... ...
@@ -52,6 +52,7 @@ func TestParseBindMount(t *testing.T) {
52 52
 		{"name:/tmp", "external", "/tmp", "", "name", "external", "", true, false},
53 53
 		{"name:/tmp:ro", "local", "/tmp", "", "name", "local", "", false, false},
54 54
 		{"local/name:/tmp:rw", "", "/tmp", "", "local/name", "local", "", true, false},
55
+		{"/tmp:tmp", "", "", "", "", "", "", true, true},
55 56
 	}
56 57
 
57 58
 	for _, c := range cases {
... ...
@@ -2,7 +2,7 @@ package daemon
2 2
 
3 3
 import "testing"
4 4
 
5
-func TestParseVolumeFrom(t *testing.T) {
5
+func TestParseVolumesFrom(t *testing.T) {
6 6
 	cases := []struct {
7 7
 		spec    string
8 8
 		expID   string
... ...
@@ -81,6 +81,11 @@ func parseBindMount(spec string, mountLabel string, config *runconfig.Config) (*
81 81
 		return nil, fmt.Errorf("Invalid volume specification: %s", spec)
82 82
 	}
83 83
 
84
+	//validate the volumes destination path
85
+	if !filepath.IsAbs(bind.Destination) {
86
+		return nil, fmt.Errorf("Invalid volume destination path: %s mount path must be absolute.", bind.Destination)
87
+	}
88
+
84 89
 	name, source, err := parseVolumeSource(arr[0])
85 90
 	if err != nil {
86 91
 		return nil, err