Skip to content

Commit 057f53f

Browse files
committed
Merge pull request moby#15846 from ZJU-SEL/11646-fix-path-validations
fix 11646 to check volume path in server side
2 parents 07d2eae + 50be74b commit 057f53f

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

daemon/volumes_linux_unit_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ func TestParseBindMount(t *testing.T) {
5252
{"name:/tmp", "external", "/tmp", "", "name", "external", "", true, false},
5353
{"name:/tmp:ro", "local", "/tmp", "", "name", "local", "", false, false},
5454
{"local/name:/tmp:rw", "", "/tmp", "", "local/name", "local", "", true, false},
55+
{"/tmp:tmp", "", "", "", "", "", "", true, true},
5556
}
5657

5758
for _, c := range cases {

daemon/volumes_unit_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package daemon
22

33
import "testing"
44

5-
func TestParseVolumeFrom(t *testing.T) {
5+
func TestParseVolumesFrom(t *testing.T) {
66
cases := []struct {
77
spec string
88
expID string

daemon/volumes_unix.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ func parseBindMount(spec string, mountLabel string, config *runconfig.Config) (*
8181
return nil, fmt.Errorf("Invalid volume specification: %s", spec)
8282
}
8383

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+
8489
name, source, err := parseVolumeSource(arr[0])
8590
if err != nil {
8691
return nil, err

0 commit comments

Comments
 (0)