if ((p = strchr(p, '/')) != NULL)
*p = '\0';
if (safe_stat(path, &st) < 0) {
- *p++ = '/';
+ if (p)
+ *p = '/';
goto done;
}
if (S_ISLNK(st.st_mode)) {
/* Like chdir(), but it keeps track of the current directory (in the
* global "curr_dir"), and ensures that the path size doesn't overflow.
* Also cleans the path using the clean_fname() function. */
-int push_dir(char *dir)
+int push_dir(char *dir, int set_path_only)
{
static int initialised;
unsigned int len;
if ((*dir == '/' ? len : curr_dir_len + 1 + len) >= sizeof curr_dir)
return 0;
- if (chdir(dir))
+ if (!set_path_only && chdir(dir))
return 0;
if (*dir == '/') {