Opened 6 years ago

#12836 new Bugs

the function canonical invalidates a path if there is double dot between two symbolic links

Reported by: Frantisek Boranek <fboranek@…> Owned by: Beman Dawes
Milestone: To Be Determined Component: filesystem
Version: Boost 1.59.0 Severity: Problem
Keywords: Cc:

Description

Create unit test like this:

void test()
{
    namespace fs = boost::filesystem;

    const fs::path base_path = createBaseDir();

    // prepare hierarchy
    fs::create_directories(base_path / "a/b/c");
    fs::create_directory_symlink(base_path / "a/b", base_path / "sym"); // base/sym -> base/a/b

    const fs::path test1 = base_path / "sym/../sym/c"; // if a symbolic link is resolved first will be ../s2 exist?
    TS_ASSERT(fs::exists(test1));
    TS_ASSERT(fs::exists(fs::canonical(test1)));
}

Test verify that path test1 exists, but the second calling of this function fails for a normalized path by function canonical. It should work otherwise the function is not reliable. The problem can be resolved if the function canonical first strip path from a dot and double dot and then resolve symbolic links.

I run the unit test only on Windows, but it should be no difference.

Change History (0)

Note: See TracTickets for help on using tickets.