Bug 9966 – Use of spawnlp and spawnl in 'link.c' does not account for paths/filenames with spaces.

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2013-04-20T01:38:33Z
Last change time
2024-12-13T18:06:14Z
Assigned to
No Owner
Creator
Paul
Moved to GitHub: dmd#18567 →

Comments

Comment #0 by psryland — 2013-04-20T01:38:33Z
The call to spawnlp (link.c, line 734ish) passes the variable 'cmd' containing a filepath to the linker as parameters 2 and 3. However if that path contains white space, the linker misinterprets the 3rd parameter as multiple command line arguments. I think the code should be changed to something like this: #if _WIN32 if (status == -1) { char* quotedCmd = (char *)alloca(strlen(cmd) + 3); sprintf(quotedCmd,"\"%s\"",cmd); // spawnlp returns intptr_t in some systems, not int status = spawnlp(0,cmd,quotedCmd,args,NULL); } #endif a similar issue exists with spawnl (link.c, line 780ish) if the linker executable should happen to contain a white space. Appologies for not just submitting a pull request, but I'm very new to the code (cloned the repo for the first time last night) and am not sure if this is the correct solution w.r.t coding conventions or the wider issues of paths with or without white space/quotes. fyi, the linker path I was using (from sc.ini) was: LINKCMD64=D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\amd64\link.exe -Paul
Comment #1 by robert.schadek — 2024-12-13T18:06:14Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18567 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB