mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-13 06:57:09 +08:00
vendor: github.com/moby/buildkit v0.13.0-rc2
full diff: https://github.com/moby/buildkit/compare/8e3fe35738c2...v0.13.0-rc2 Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
22
vendor/github.com/tonistiigi/fsutil/validator.go
generated
vendored
22
vendor/github.com/tonistiigi/fsutil/validator.go
generated
vendored
@ -2,8 +2,7 @@ package fsutil
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path"
|
||||
"runtime"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"syscall"
|
||||
@ -28,21 +27,18 @@ func (v *Validator) HandleChange(kind ChangeKind, p string, fi os.FileInfo, err
|
||||
if v.parentDirs == nil {
|
||||
v.parentDirs = make([]parent, 1, 10)
|
||||
}
|
||||
if runtime.GOOS == "windows" {
|
||||
p = strings.Replace(p, "\\", "", -1)
|
||||
}
|
||||
if p != path.Clean(p) {
|
||||
if p != filepath.Clean(p) {
|
||||
return errors.WithStack(&os.PathError{Path: p, Err: syscall.EINVAL, Op: "unclean path"})
|
||||
}
|
||||
if path.IsAbs(p) {
|
||||
if filepath.IsAbs(p) {
|
||||
return errors.WithStack(&os.PathError{Path: p, Err: syscall.EINVAL, Op: "absolute path"})
|
||||
}
|
||||
dir := path.Dir(p)
|
||||
base := path.Base(p)
|
||||
dir := filepath.Dir(p)
|
||||
base := filepath.Base(p)
|
||||
if dir == "." {
|
||||
dir = ""
|
||||
}
|
||||
if dir == ".." || strings.HasPrefix(p, "../") {
|
||||
if dir == ".." || strings.HasPrefix(p, filepath.FromSlash("../")) {
|
||||
return errors.WithStack(&os.PathError{Path: p, Err: syscall.EINVAL, Op: "escape check"})
|
||||
}
|
||||
|
||||
@ -56,12 +52,12 @@ func (v *Validator) HandleChange(kind ChangeKind, p string, fi os.FileInfo, err
|
||||
}
|
||||
|
||||
if dir != v.parentDirs[len(v.parentDirs)-1].dir || v.parentDirs[i].last >= base {
|
||||
return errors.Errorf("changes out of order: %q %q", p, path.Join(v.parentDirs[i].dir, v.parentDirs[i].last))
|
||||
return errors.Errorf("changes out of order: %q %q", p, filepath.Join(v.parentDirs[i].dir, v.parentDirs[i].last))
|
||||
}
|
||||
v.parentDirs[i].last = base
|
||||
if kind != ChangeKindDelete && fi.IsDir() {
|
||||
v.parentDirs = append(v.parentDirs, parent{
|
||||
dir: path.Join(dir, base),
|
||||
dir: filepath.Join(dir, base),
|
||||
last: "",
|
||||
})
|
||||
}
|
||||
@ -76,7 +72,7 @@ func ComparePath(p1, p2 string) int {
|
||||
switch {
|
||||
case p1[i] == p2[i]:
|
||||
continue
|
||||
case p2[i] != '/' && p1[i] < p2[i] || p1[i] == '/':
|
||||
case p2[i] != filepath.Separator && p1[i] < p2[i] || p1[i] == filepath.Separator:
|
||||
return -1
|
||||
default:
|
||||
return 1
|
||||
|
Reference in New Issue
Block a user