Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make_path_absolute can be wrong when path contains symlinks #11

Open
jpcima opened this issue Nov 13, 2019 · 0 comments
Open

make_path_absolute can be wrong when path contains symlinks #11

jpcima opened this issue Nov 13, 2019 · 0 comments

Comments

@jpcima
Copy link
Owner

jpcima commented Nov 13, 2019

It will be wrong to simplify a path by elimination of foo/../ kind of patterns, in case foo is a symlink.

The directory part of path may be resolved by file system API:

  • POSIX realpath
  • Windows GetFinalPathNameByHandleA (_WIN32_WINNT >= 0x0600)
  • Older Windows has no symlinks, so it's fine to use the old method.
HANDLE hDirectory = CreateFile(
    path,
    0,
    FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
    nullptr,
    OPEN_EXISTING,
    FILE_FLAG_BACKUP_SEMANTICS,
    nullptr);

GetFinalPathNameByHandleA(
    hDirectory,
    path,
    pathlen,
    VOLUME_NAME_DOS|FILE_NAME_NORMALIZED);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant