[BusyBox] [PATCH] `which' doesn't check whether file is a regular file.
Arthur Othieno
a.othieno at bluewin.ch
Fri Oct 24 18:47:09 UTC 2003
Greetings,
The previous fix introduced a bug where `which' doesn't check whether
the file passed as an argument is a regular file. Demonstrated in the
transcript below:
debianutils 2.5.5:
hubb at mars:~/devel/busybox$ which /bin
hubb at mars:~/devel/busybox$
busybox-1.0.0-pre3:
hubb at mars:~/devel/busybox$ ./busybox which /bin/
/bin/
hubb at mars:~/devel/busybox$
Please apply.
Regards,
Arthur.
--
Linux is a true multitasking system. Are you?
-------------- next part --------------
Index: debianutils/which.c
===================================================================
RCS file: /var/cvs/busybox/debianutils/which.c,v
retrieving revision 1.5
diff -u -r1.5 which.c
--- debianutils/which.c 22 Oct 2003 11:36:55 -0000 1.5
+++ debianutils/which.c 24 Oct 2003 15:16:26 -0000
@@ -30,7 +30,9 @@
{
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;
More information about the busybox
mailing list