]> git.ipfire.org Git - thirdparty/ccache.git/commit
refactor: Improve absolute path normalization functions
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 27 Apr 2022 19:15:35 +0000 (21:15 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sat, 30 Apr 2022 18:14:45 +0000 (20:14 +0200)
commit9a05332915d2808f4713437006b3f7c812d9fd74
tree2ea158d6860ced81d4e8107798735219a82c0c0c
parent3f4b6d6fc0a6c60e28d66178a53010a602b87280
refactor: Improve absolute path normalization functions

The Util::normalize_absolute_path function only works on the syntactic
level, i.e. the result may not actually resolve to the same filesystem
entry (nor to any file system entry for that matter). It was meant to be
used for paths that don’t necessarily exist yet, such as a future
directory in which to write debug files. It may fail in edge cases with
symlinks in the path in combination with .. segments. If the caller
wants to ensure that the resulting path actually makes sense, it needs
to check if the resulting path points to the same file entry as the
original.

To improve on this, Util::normalize_absolute_path has now been renamed
to Util::normalize_abstract_absolute_path and there is a new
Util::normalize_concrete_absolute_path function which returns the
original path if the normalized result doesn't resolve to the same file
system entry as the original path.
src/Config.cpp
src/Util.cpp
src/Util.hpp
src/util/path.cpp
unittest/test_Util.cpp