aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/find
diff options
context:
space:
mode:
authorJilles Tjoelker <jilles@FreeBSD.org>2013-02-10 13:28:02 +0000
committerJilles Tjoelker <jilles@FreeBSD.org>2013-02-10 13:28:02 +0000
commitbc62617630671fffad64dfb8bb404534a59f3476 (patch)
treecc60cafdaa059a336ae072a33702fe68357eb46d /usr.bin/find
parent08851ea288ed577060974bf8347dad0350c29a54 (diff)
downloadsrc-bc62617630671fffad64dfb8bb404534a59f3476.tar.gz
src-bc62617630671fffad64dfb8bb404534a59f3476.zip
find: In -execdir ... {} +, only pass one file per invocation.
This is inefficient but ensures that -execdir ... {} + does not mix files from different directories in one invocation; the command could not access some files. Files from the same directory should really be handled in one invocation but this is somewhat more complicated.
Notes
Notes: svn path=/head/; revision=246618
Diffstat (limited to 'usr.bin/find')
-rw-r--r--usr.bin/find/function.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c
index 5f8f8130432d..4f2eba7433f2 100644
--- a/usr.bin/find/function.c
+++ b/usr.bin/find/function.c
@@ -711,7 +711,13 @@ c_exec(OPTION *option, char ***argvp)
for (ep = environ; *ep != NULL; ep++)
argmax -= strlen(*ep) + 1 + sizeof(*ep);
argmax -= 1 + sizeof(*ep);
- new->e_pnummax = argmax / 16;
+ /*
+ * Ensure that -execdir ... {} + does not mix files
+ * from different directories in one invocation.
+ * Files from the same directory should be handled
+ * in one invocation but there is no code for it.
+ */
+ new->e_pnummax = new->flags & F_EXECDIR ? 1 : argmax / 16;
argmax -= sizeof(char *) * new->e_pnummax;
if (argmax <= 0)
errx(1, "no space for arguments");