aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2026-06-19 19:13:54 +0100
committerRon Yorston <rmy@pobox.com>2026-06-19 19:13:54 +0100
commit228ee18fbe8cf408440e7bbe91db4ef201312983 (patch)
tree516e6a0795879208cbba5f5493c567fb8f1b843d
parenta717c68449c8df642f6f2381618366a24734d184 (diff)
downloadbusybox-w32-228ee18fbe8cf408440e7bbe91db4ef201312983.tar.gz
busybox-w32-228ee18fbe8cf408440e7bbe91db4ef201312983.tar.bz2
busybox-w32-228ee18fbe8cf408440e7bbe91db4ef201312983.zip
find: reset stat(2) flags before terminating
Commit a717c6844 (find: skip check for execute when not needed) didn't reset stat(2) to its default behaviour (at my insistence). This was incorrect. The '-exec cmd {} +' action calls a nofork 'cmd' directly without spawning a new process. If 'cmd' calls 'stat(2)' it won't be in its default state which can affect the result. Reintroduce the code to reset 'stat(2)'. Adds 16 bytes. (GitHub PR #600) Signed-off-by: Ron Yorston <rmy@pobox.com>
-rw-r--r--findutils/find.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/findutils/find.c b/findutils/find.c
index bdca6d08a..f2b5c4ace 100644
--- a/findutils/find.c
+++ b/findutils/find.c
@@ -1759,7 +1759,6 @@ int find_main(int argc UNUSED_PARAM, char **argv)
1759#if ENABLE_PLATFORM_MINGW32 1759#if ENABLE_PLATFORM_MINGW32
1760 /* Do this all the time. That way we prevent doing double-stats for 1760 /* Do this all the time. That way we prevent doing double-stats for
1761 executable files (the executable check above uses access() which calls stat again) 1761 executable files (the executable check above uses access() which calls stat again)
1762 And we don't need to worry about resetting at the end since this isn't a NOFORK applet.
1763 */ 1762 */
1764 stat_flag = BB_STAT_NO_HAS_EXEC_FORMAT; 1763 stat_flag = BB_STAT_NO_HAS_EXEC_FORMAT;
1765 stat(&stat_flag, NULL); 1764 stat(&stat_flag, NULL);
@@ -1776,6 +1775,13 @@ int find_main(int argc UNUSED_PARAM, char **argv)
1776 } 1775 }
1777 } 1776 }
1778 1777
1778#if ENABLE_PLATFORM_MINGW32
1779 /* Reinstate costly check for executables. flush_exec_plus() may
1780 * invoke a NOFORK applet */
1781 stat_flag = 0;
1782 stat(&stat_flag, NULL);
1783#endif
1784
1779 IF_FEATURE_FIND_EXEC_PLUS(G.exitstatus |= flush_exec_plus();) 1785 IF_FEATURE_FIND_EXEC_PLUS(G.exitstatus |= flush_exec_plus();)
1780 return G.exitstatus; 1786 return G.exitstatus;
1781} 1787}