https://bugs.winehq.org/show_bug.cgi?id=48449
Bug ID: 48449 Summary: 'CreateProcess(0, "cmd /C [...]' fails when a trailing newline follows a redirect in the cmdline Product: Wine Version: 5.0-rc5 Hardware: x86 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: -unknown Assignee: wine-bugs@winehq.org Reporter: timotheecisnard@gmail.com Distribution: ---
Applications using CreateProcess to invoke "cmd.exe /C" followed by a command, a redirect to a file, and a newline, result in an "Invalid name" error and the command not being run. The expected result on Windows is for the trailing newline to be silently ignored and not treated as part of the file name being redirected into.
For example, the CreateProcess cmdline "cmd.exe /C echo OK >> test.log\n" contains a (completely pointless) trailing newline. Note that the newline is a literal trailing 0x0A character in a cmdline and NOT an interactive user pressing Enter at a command prompt.
This issue is best reproduced with a 10 line C program: https://paste.debian.net/1125644/
The bug originally affects ALDEC Active-HDL Lattice Edition 32bit version 10.5.216.6767, where compiling a project works but starting a simulation fails at the linking step with cryptic errors like "Generation phase ... fail" and "Error: E8005 : Kernel process initialization failed.".
https://bugs.winehq.org/show_bug.cgi?id=48449
timotheecisnard@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |source
https://bugs.winehq.org/show_bug.cgi?id=48449
--- Comment #1 from timotheecisnard@gmail.com --- Adding the reproducer inline since the Debian paste has had plenty of time to expire =)
``` #include <windows.h> #include <string>
using namespace std;
int main(int argc, char* argv[]) { string cmdline = "cmd.exe /Q /C "echo 2" >> out.txt\n";
PROCESS_INFORMATION piProcInfo; STARTUPINFOA siStartInfo; ZeroMemory(&piProcInfo, sizeof(PROCESS_INFORMATION)); ZeroMemory(&siStartInfo, sizeof(STARTUPINFOA)); siStartInfo.cb = sizeof(STARTUPINFOA); CreateProcessA(nullptr, (char*)cmdline.data(), nullptr, nullptr, false, 0, nullptr, nullptr, &siStartInfo, &piProcInfo); CloseHandle(piProcInfo.hProcess); CloseHandle(piProcInfo.hThread); } ```
On Windows, this will create "out.txt" as expected, on Wine this prints "Invalid name." and the command is not run.
https://bugs.winehq.org/show_bug.cgi?id=48449
timotheecisnard@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Distribution|--- |Debian Hardware|x86 |x86-64 Version|5.0-rc5 |5.0.3