Skip to content

BoundOS.abs recurses forever when baseDir is empty #209

@andrew

Description

@andrew

With an empty base dir and the default deduplicatePath, abs calls itself with the same input:

osfs.New("", osfs.WithBoundOS()).Stat("/tmp")
// fatal error: stack overflow

In os_bound.go abs:

dup := filepath.Join(fs.baseDir, fs.baseDir[len(vol):])           // "" when baseDir == ""
if strings.HasPrefix(path, dup+string(filepath.Separator)) {      // HasPrefix(path, "/") -> true
    return fs.abs(path[len(dup):])                                // fs.abs(path) -> same input
}

Reproduced on v5.8.0 and v5.9.0, darwin/arm64.

Happy to send a PR. Guarding the dedup block with fs.baseDir != "" (or dup != "") fixes it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions