security: protect multi-root virtual mounts

This commit is contained in:
OpenClaw Agent
2026-09-21 22:38:02 +08:00
parent bf526cac2a
commit 18d5d29a09
2 changed files with 22 additions and 7 deletions
+7 -7
View File
@@ -109,24 +109,24 @@ func (m Multi) Create(p string) (*os.File, error) {
}
func (m Multi) Remove(p string) error {
r, rel, ok := m.find(p)
if !ok {
return os.ErrNotExist
if !ok || rel == "" {
return os.ErrInvalid
}
return r.Remove(rel)
}
func (m Multi) Trash(p string) error {
r, rel, ok := m.find(p)
if !ok {
return os.ErrNotExist
if !ok || rel == "" {
return os.ErrInvalid
}
return r.Trash(rel)
}
func (m Multi) MoveToTrash(p, trashRoot string) error {
r, rel, ok := m.find(p)
if !ok {
return os.ErrNotExist
if !ok || rel == "" {
return os.ErrInvalid
}
return r.MoveToTrash(rel, filepath.Join(trashRoot, m.RootName(r)))
}
@@ -142,7 +142,7 @@ func (m Multi) RootName(r Local) string {
func (m Multi) Rename(a, b string) error {
ra, aa, oka := m.find(a)
rb, bb, okb := m.find(b)
if !oka || !okb || ra.Root != rb.Root {
if !oka || !okb || aa == "" || bb == "" || ra.Root != rb.Root {
return os.ErrInvalid
}
return ra.Rename(aa, bb)