1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

fix 'args list too long' on Linux, again (re: 63979488)

That fix turned out to be insufficient as NixOS has huge
environment variable lists because (due to each software package
being installed in its own directory tree) it has to keep dozens
of directories in variables like XDG_CONFIG_DIRS and others.
The 'command -x' regression test was failing on NixOS.

src/cmd/ksh93/sh/path.c:
- Different strategy. Leave twice the size of the existing
  environment free.
This commit is contained in:
Martijn Dekker 2021-02-03 18:38:14 +00:00
parent 7ff6b73bdb
commit 8f5235a53f

View file

@ -162,9 +162,9 @@ static pid_t path_xargs(Shell_t *shp,const char *path, char *argv[],char *const
pid_t pid;
if(shp->xargmin < 0)
return((pid_t)-1);
size = shp->gd->lim.arg_max - (ARG_EXTRA_BYTES > 2 ? 1024*ARG_EXTRA_BYTES : 2048);
size = shp->gd->lim.arg_max - 2048;
for(ev=envp; cp= *ev; ev++)
size -= strlen(cp) + 1 + ARG_EXTRA_BYTES;
size -= 2 * (strlen(cp) + 1 + ARG_EXTRA_BYTES);
for(av=argv; (cp= *av) && av< &argv[shp->xargmin]; av++)
size -= strlen(cp) + 1 + ARG_EXTRA_BYTES;
for(av=avlast; cp= *av; av++,nlast++)