Skip to content

Commit 6979282

Browse files
committed
libct/cg: don't use utils.CleanPath
Instead, we can just do filepath.Clean("/"+path) here. While at it, add a comment telling why this is needed and important. Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent 5e1dcdf commit 6979282

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

libcontainer/cgroups/file.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ import (
55
"errors"
66
"fmt"
77
"os"
8-
"path"
8+
"path/filepath"
99
"strconv"
1010
"strings"
1111
"sync"
1212

13-
"github.com/opencontainers/runc/libcontainer/utils"
1413
"github.com/sirupsen/logrus"
1514
"golang.org/x/sys/unix"
1615
)
@@ -147,7 +146,10 @@ func openFile(dir, file string, flags int) (*os.File, error) {
147146
flags |= os.O_TRUNC | os.O_CREATE
148147
mode = 0o600
149148
}
150-
path := path.Join(dir, utils.CleanPath(file))
149+
// NOTE it is important to use filepath.Clean("/"+file) here
150+
// (see https://github.com/opencontainers/runc/issues/4103)!
151+
path := filepath.Join(dir, filepath.Clean("/"+file))
152+
151153
if prepareOpenat2() != nil {
152154
return openFallback(path, flags, mode)
153155
}

0 commit comments

Comments
 (0)