fix a bug where `which' doesn't check whether the file passed as an argument
is a regular file, patch by Arthur Othieno
This commit is contained in:
@ -30,7 +30,9 @@ static int file_exists(char *file)
|
|||||||
{
|
{
|
||||||
struct stat filestat;
|
struct stat filestat;
|
||||||
|
|
||||||
if (stat(file, &filestat) == 0 && filestat.st_mode & S_IXUSR)
|
if (stat(file, &filestat) == 0 &&
|
||||||
|
S_ISREG(filestat.st_mode) &&
|
||||||
|
filestat.st_mode & S_IXUSR)
|
||||||
return 1;
|
return 1;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user