[PATCH] Use fs.RootPath when mounting volumes

Signed-off-by: Ruiwen Zhao <ruiwen@google.com>

Gbp-Pq: Name CVE-2022-23648.patch
This commit is contained in:
ruiwen-zhao 2022-02-11 04:21:58 +00:00 committed by luoyaoming
parent 4cde249d7b
commit 3b34805efb
1 changed files with 4 additions and 2 deletions

View File

@ -20,7 +20,6 @@ import (
"context"
"io/ioutil"
"os"
"path/filepath"
"github.com/containerd/containerd"
"github.com/containerd/containerd/containers"
@ -89,7 +88,10 @@ func WithVolumes(volumeMounts map[string]string) containerd.NewContainerOpts {
}()
for host, volume := range volumeMounts {
src := filepath.Join(root, volume)
src, err := fs.RootPath(root, volume)
if err != nil {
return errors.Wrapf(err, "rootpath on root %s, volume %s", root, volume)
}
if _, err := os.Stat(src); err != nil {
if os.IsNotExist(err) {
// Skip copying directory if it does not exist.