Commit 472fbb8b authored by Michael Haubenwallner's avatar Michael Haubenwallner Committed by Corinna Vinschen

Cygwin: build_env: fix off-by-one bug when re-adding PATH

Adding default winvar 'PATH=C:\cygwin64\binZ' to an environment that is
already allocated for 'SYSTEMROOT=ZWINDIR=Z', we need to count that
trailing (Z)ero as well.  Otherwise we trigger this assertion failure:

$ /bin/env -i SYSTEMROOT= WINDIR= /bin/env
assertion "(s - envblock) <= tl" failed: file "/home/corinna/src/cygwin/cygwin-3.0.7/cygwin-3.0.7-1.x86_64/src/newlib-cygwin/winsup/cygwin/", line 1302, function: char** build_env(const char* const*, WCHAR*&, int&, bool, HANDLE)
Aborted (core dumped)
parent 98669a24
...@@ -1295,7 +1295,7 @@ build_env (const char * const *envp, PWCHAR &envblock, int &envc, ...@@ -1295,7 +1295,7 @@ build_env (const char * const *envp, PWCHAR &envblock, int &envc,
during execve. */ during execve. */
if (!saw_PATH) if (!saw_PATH)
{ {
new_tl += cygheap->installation_dir.Length / sizeof (WCHAR) + 5; new_tl += cygheap->installation_dir.Length / sizeof (WCHAR) + 5 + 1;
if (new_tl > tl) if (new_tl > tl)
tl = raise_envblock (new_tl, envblock, s); tl = raise_envblock (new_tl, envblock, s);
s = wcpcpy (wcpcpy (s, L"PATH="), s = wcpcpy (wcpcpy (s, L"PATH="),
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment