diff options
Diffstat (limited to 'internal/httpfs/http_fs.go')
-rw-r--r-- | internal/httpfs/http_fs.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/internal/httpfs/http_fs.go b/internal/httpfs/http_fs.go index 1e9dff1c..17518301 100644 --- a/internal/httpfs/http_fs.go +++ b/internal/httpfs/http_fs.go @@ -83,6 +83,13 @@ func (p *fileSystemPaths) Open(name string) (http.File, error) { return nil, err } for _, allowedPath := range p.allowedPaths { + // filepath.Abs(allowedPath) in NewFileSystemPath resolves an allowedPath to be `/` when + // chrootPath == allowedPath, so we need to return early if in chroot + //and we have stripped p.chrootPath from absPath && allowedPath + if p.chrootPath != "" && allowedPath == "/" { + return os.Open(absPath) + } + if strings.HasPrefix(absPath, allowedPath+"/") { return os.Open(absPath) } |