[OpenWrt-Devel,7/8] tools/findutils: improve cygwin compatibility
diff mbox series

Message ID 20191008010225.8822-7-rosenp@gmail.com
State Rejected
Delegated to: Petr Štetiar
Headers show
Series
  • [OpenWrt-Devel,1/8] ncurses: add cygwin compatibility
Related show

Commit Message

Rosen Penev Oct. 8, 2019, 1:02 a.m. UTC
From: Alexey Loukianov <lx2@lexa2.ru>

Environment block size on Windows is limited to ~32k. But
contrary to typical posix limitation process arguments are
not included in environment block and are separate from it.
Thus it is not required to compare env_size with arg_max
when checking for execl(e) limits in findutils.

This is important due to a fact that some software like
linux kernel backports tend to export a lot of environment
variables during build which leads to find/xargs failing
with "environment is too large for exec" message when
working under cygwin.

Signed-off-by: Alexey Loukianov <lx2@lexa2.ru>
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 ...cygwin-env-is-not-included-into-args.patch | 33 +++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 tools/findutils/patches/900-cygwin-env-is-not-included-into-args.patch

Patch
diff mbox series

diff --git a/tools/findutils/patches/900-cygwin-env-is-not-included-into-args.patch b/tools/findutils/patches/900-cygwin-env-is-not-included-into-args.patch
new file mode 100644
index 0000000000..d96b2fce91
--- /dev/null
+++ b/tools/findutils/patches/900-cygwin-env-is-not-included-into-args.patch
@@ -0,0 +1,33 @@ 
+Index: findutils-4.6.0/lib/buildcmd.c
+===================================================================
+--- findutils-4.6.0.orig/lib/buildcmd.c
++++ findutils-4.6.0/lib/buildcmd.c
+@@ -509,6 +509,8 @@ bc_init_controlinfo (struct buildcmd_con
+ 
+   ctl->exit_if_size_exceeded = 0;
+ 
++
++#ifndef __CYGWIN__
+   /* Take the size of the environment into account.  */
+   if (size_of_environment > ctl->posix_arg_size_max)
+     {
+@@ -525,9 +527,19 @@ bc_init_controlinfo (struct buildcmd_con
+     }
+   else
+     {
++      ctl->posix_arg_size_max -= headroom;
+       ctl->posix_arg_size_max -= size_of_environment;
++    }
++#else
++  if (headroom >= ctl->posix_arg_size_max)
++    {
++      return BC_INIT_CANNOT_ACCOMODATE_HEADROOM;
++    }
++  else
++    {
+       ctl->posix_arg_size_max -= headroom;
+     }
++#endif
+ 
+   /* need to subtract 2 on the following line - for Linux/PPC */
+   ctl->max_arg_count = (ctl->posix_arg_size_max / sizeof (char*)) - 2u;