https://bugs.winehq.org/show_bug.cgi?id=37635
Bug ID: 37635 Summary: Explicit environment variables passed to spawn/exec are corrupted Product: Wine Version: 1.7.30 Hardware: x86 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: msvcrt Assignee: wine-bugs@winehq.org Reporter: rmy@pobox.com Distribution: ---
Created attachment 50088 --> https://bugs.winehq.org/attachment.cgi?id=50088 msvcrt: Fix passing of explicit environment to spawn/exec calls
Consider the following:
char *arg[2] = { "./printenv.exe", NULL }; char *env[2] = { "HELLO=world", NULL }; spawnve(P_WAIT, arg[0], arg, env);
Where printenv.exe just prints the environment:
char **e; for (e=environ; *e; ++e) printf("%s\n", *e);
On Windows this results in:
HELLO=world SystemRoot=C:\Windows
Wine gives:
H E L L O = w o r l d ProgramFiles=C:\Program Files CommonProgramFiles=C:\Program Files\Common Files
This happens because the spawn/exec routines convert the supplied environment variables into a wide-character environment block. This is passed to CreateProcessW but without adding CREATE_UNICODE_ENVIRONMENT to the creation flags. In create_process_impl in kernel32 the lack of CREATE_UNICODE_ENVIRONMENT causes the environment block to be run through a second conversion to wide characters.
https://bugs.winehq.org/show_bug.cgi?id=37635
--- Comment #1 from Ken Thomases ken@codeweavers.com --- Thanks for the bug report and patch. Patches are not picked up from bug reports, so please submit it as per http://wiki.winehq.org/SubmittingPatches.
Is there a reason why CREATE_UNICODE_ENVIRONMENT can't just be passed unconditionally?
https://bugs.winehq.org/show_bug.cgi?id=37635
--- Comment #2 from Ron Yorston rmy@pobox.com ---
Is there a reason why CREATE_UNICODE_ENVIRONMENT can't just be passed >unconditionally?
I don't think so, I was just being cautious.
https://bugs.winehq.org/show_bug.cgi?id=37635
Sebastian Lackner sebastian@fds-team.de changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |sebastian@fds-team.de
--- Comment #3 from Sebastian Lackner sebastian@fds-team.de --- You should remove the check of 'env', this makes the patch look more complicated than it is. Kernel32 already ensures that the environment variable is never accessed when a NULL pointer is passed.
A simplified version of this patch was added to Wine Staging: https://github.com/wine-compholio/wine-staging/blob/master/patches/msvcrt-Sp...
https://bugs.winehq.org/show_bug.cgi?id=37635
Piotr Caban piotr.caban@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Fixed by SHA1| |a4fcba60b9a8084e8a579e503a8 | |3c5241f437135 Status|UNCONFIRMED |RESOLVED CC| |piotr.caban@gmail.com Resolution|--- |FIXED
--- Comment #4 from Piotr Caban piotr.caban@gmail.com --- It's fixed in wine. Thanks you.
https://bugs.winehq.org/show_bug.cgi?id=37635
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #5 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 1.7.33.