Merge pull request from GHSA-crp2-qrr5-8pq7

Clean image volume path
This commit is contained in:
Derek McGowan 2022-03-02 10:03:17 -08:00 committed by GitHub
commit 8acbb27647
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -112,7 +112,10 @@ func WithVolumes(volumeMounts map[string]string) containerd.NewContainerOpts {
// The volume may have been defined with a C: prefix, which we can't use here.
volume = strings.TrimPrefix(volume, "C:")
for _, mountPath := range mountPaths {
src := filepath.Join(mountPath, volume)
src, err := fs.RootPath(mountPath, volume)
if err != nil {
return fmt.Errorf("rootpath on mountPath %s, volume %s: %w", mountPath, volume, err)
}
if _, err := os.Stat(src); err != nil {
if os.IsNotExist(err) {
// Skip copying directory if it does not exist.