add handling of a '.' commondir and bounds checking to mount_linux
Signed-off-by: Craig Ingram <Cjingram@google.com>
This commit is contained in:
parent
4b7145cfd3
commit
d2605de734
@ -274,13 +274,16 @@ func compactLowerdirOption(opts []string) (string, []string) {
|
|||||||
// in order to avoid to get snapshots/x, should be back to parent dir.
|
// in order to avoid to get snapshots/x, should be back to parent dir.
|
||||||
// however, there is assumption that the common dir is ${root}/io.containerd.v1.overlayfs/snapshots.
|
// however, there is assumption that the common dir is ${root}/io.containerd.v1.overlayfs/snapshots.
|
||||||
commondir = path.Dir(commondir)
|
commondir = path.Dir(commondir)
|
||||||
if commondir == "/" {
|
if commondir == "/" || commondir == "." {
|
||||||
return "", opts
|
return "", opts
|
||||||
}
|
}
|
||||||
commondir = commondir + "/"
|
commondir = commondir + "/"
|
||||||
|
|
||||||
newdirs := make([]string, 0, len(dirs))
|
newdirs := make([]string, 0, len(dirs))
|
||||||
for _, dir := range dirs {
|
for _, dir := range dirs {
|
||||||
|
if len(dir) <= len(commondir) {
|
||||||
|
return "", opts
|
||||||
|
}
|
||||||
newdirs = append(newdirs, dir[len(commondir):])
|
newdirs = append(newdirs, dir[len(commondir):])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +84,13 @@ func TestCompactLowerdirOption(t *testing.T) {
|
|||||||
"",
|
"",
|
||||||
[]string{"lowerdir=/snapshots/1/fs:/other_snapshots/1/fs"},
|
[]string{"lowerdir=/snapshots/1/fs:/other_snapshots/1/fs"},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// if common dir is .
|
||||||
|
{
|
||||||
|
[]string{"lowerdir=a:aaa"},
|
||||||
|
"",
|
||||||
|
[]string{"lowerdir=a:aaa"},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, tc := range tcases {
|
for i, tc := range tcases {
|
||||||
|
Loading…
Reference in New Issue
Block a user