lib9p

Go 9P library.
Log | Files | Refs | LICENSE

commit 0604313fa77458c4d504f82453a491469a2ccc9b
parent ebcc8cd584bc946e400913e0d2a51640a66c697d
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Sun,  7 Jan 2024 13:24:18 +0900

restrict walk inside the file tree

Diffstat:
Mserver.go | 7+++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/server.go b/server.go @@ -373,6 +373,7 @@ func sFlush(ctx context.Context, c *conn, rc <-chan *request) { } } +// TODO: implement MAXWELEM. func sWalk(ctx context.Context, c *conn, rc <-chan *request) { for { select { @@ -421,9 +422,11 @@ func sWalk(ctx context.Context, c *conn, rc <-chan *request) { } wqids = make([]Qid, len(ifcall.Wnames)) cwdp = oldFid.path - // TODO: replace this block with fs.WalkDir. for i, name := range ifcall.Wnames { - cwdp = path.Join(cwdp, name) + cwdp = path.Clean(path.Join(cwdp, name)) + if cwdp == ".." { + cwdp = "." // parent of the root is itself. + } stat, err := fs.Stat(ExportFS{c.s.fs}, cwdp) if err != nil { break