busybox/findutils
James Clarke 6bcc2c0f6c grep: skip grepping symlinks to directories
When grep is passed -r, recursive_action will treat any symlinks to
directories not in the root as normal files, since it lstat's them and
is therefore told they are not directories. However, file_action_grep
will still try to fopen and read from them to see whether they match,
which varies in behaviour across platforms. Linux will give EISDIR and
thus grep will not find any matching lines, but FreeBSD will give the
raw contents of the directory itself, which may match the given pattern.
Also, if grep is passed -c, it will even print a count for these
symlinks, even on Linux.

Since this recursive_action behaviour is required for the correct
functioning of other applets, such as tar, grep should handle this
special case and skip any such symlinks.

function                                             old     new   delta
file_action_grep                                      80     161     +81

Signed-off-by: James Clarke <jrtc27@jrtc27.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-10-31 15:23:55 +01:00
..
Config.src
find.c regularize format of source file headers, no code changes 2017-09-18 16:28:43 +02:00
grep.c grep: skip grepping symlinks to directories 2017-10-31 15:23:55 +01:00
Kbuild.src *: make GNU licensing statement forms more regular 2010-08-16 20:14:46 +02:00
xargs.c xargs: fix a thinko in last commit 2017-08-30 13:44:27 +02:00