diff --git a/ccache.c b/ccache.c index ea9b39b..498e8ad 100644 --- a/ccache.c +++ b/ccache.c @@ -2465,7 +2484,22 @@ initialize(void) umask(conf->umask); } - current_working_dir = get_cwd(); + /* set current_working_dir in a canonical form */ + { + char *cp; + cp = get_cwd(); + if(cp) { + /* canonicalize, resolve symlink, etc. */ + current_working_dir = x_realpath(cp); + free(cp); + } + if(!current_working_dir) { + cc_log("Unable to determine current working directory: %s", + strerror(errno)); + failed(); + } + } + } /* Reset the global state. Used by the test suite. */