]> git.ipfire.org Git - thirdparty/ccache.git/commit
fix: Avoid expanding symlinks in relative path candidates
authorJoel Rosdahl <joel@rosdahl.net>
Tue, 9 Sep 2025 16:34:34 +0000 (18:34 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 9 Sep 2025 19:04:20 +0000 (21:04 +0200)
commit8810fadab0b59c03cff4c4dc24b00c571a0786ba
treea8b5588293bd8220af84f49e964d9719f8c8c311
parent4608f018e7a6ae542370150375056925992cb86b
fix: Avoid expanding symlinks in relative path candidates

Commit 8223ed38abd9cf75ab75cb19dc2081c44bf568d0 changed
make_relative_path to also try matching real_path(path) against the
apparent/actual CWD, assuming that an absolute path p could be
substituted with real_path(p).

This assumption is incorrect for source files: if the source file
includes a file via a relative path, expanding symlinks may cause the
include file to be searched in the wrong directory.

Fix by reverting that change. The new test case "Symlink to source file,
longer symlink path" fails without this fix.

Note: this effectively reverts #724.

Fixes #1620.
src/ccache/util/path.cpp
test/suites/basedir.bash
unittest/test_util_path.cpp