From 984b45142a1771edcd28c9f7e2fa3269e7e2dde3 Mon Sep 17 00:00:00 2001 From: Glenn L McGrath Date: Wed, 29 Oct 2003 04:50:35 +0000 Subject: fix a bug where `which' doesn't check whether the file passed as an argument is a regular file, patch by Arthur Othieno --- debianutils/which.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'debianutils/which.c') diff --git a/debianutils/which.c b/debianutils/which.c index 27646d520..120f1e72f 100644 --- a/debianutils/which.c +++ b/debianutils/which.c @@ -30,7 +30,9 @@ static int file_exists(char *file) { 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; else return 0; -- cgit v1.2.3