Skip to content

Commit

Permalink
Don't call realpath() on fake pathnames like "-" and FAKE_HELPFILE.
Browse files Browse the repository at this point in the history
  • Loading branch information
gwsw committed Dec 6, 2022
1 parent 71a8cf7 commit ccb6da0
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions filename.c
Original file line number Diff line number Diff line change
Expand Up @@ -797,18 +797,32 @@ lglob(filename)
return (gfilename);
}

/*
* Does path not represent something in the file system?
*/
public int
is_fake_pathname(path)
char *path;
{
return (strcmp(path, "-") == 0 ||
strcmp(path, FAKE_HELPFILE) == 0 || strcmp(path, FAKE_EMPTYFILE) == 0);
}

/*
* Return canonical pathname.
*/
public char *
lrealpath(path)
char *path;
{
if (!is_fake_pathname(path))
{
#if HAVE_REALPATH
char rpath[PATH_MAX];
if (realpath(path, rpath) != NULL)
return (save(rpath));
char rpath[PATH_MAX];
if (realpath(path, rpath) != NULL)
return (save(rpath));
#endif
}
return (save(path));
}

Expand Down

0 comments on commit ccb6da0

Please sign in to comment.