http://bugs.winehq.org/show_bug.cgi?id=4335
Summary: _tempnam does not check for the environment variable TMP Product: Wine Version: 0.9.5. Platform: Other OS/Version: All Status: UNCONFIRMED Severity: normal Priority: P3 Component: wine-files AssignedTo: wine-bugs@winehq.org ReportedBy: sascha93101@yahoo.com
_tempnam should follow the rules described here: http://msdn2.microsoft.com/en-us/library/hs3e7355.aspx
When the Microsoft linker links an executable using a resource file, it calls _tempnam to get a name for a temporary files. Since TMP is ignored, the linker gets back the name "/lnk**.tmp". In most cases, the user running linker doesn't and shouldn't have write permissions in the root directory, and the linker fails.
The fixed code is here: char *_tempnam(const char *dir, const char *prefix) { char tmpbuf[MAX_PATH]; char save_TMP[MAX_PATH]; const char *tmp_dir = dir;
if (GetEnvironmentVariableA("TMP",save_TMP,sizeof(save_TMP))) { tmp_dir = save_TMP; }
TRACE("dir (%s) prefix (%s)\n",tmp_dir,prefix); if (GetTempFileNameA(tmp_dir,prefix,0,tmpbuf)) { TRACE("got name (%s)\n",tmpbuf); DeleteFileA(tmpbuf); return _strdup(tmpbuf); } TRACE("failed (%ld)\n",GetLastError()); return NULL; }
I'll send it to wine-patches@winehq.org too. Also, http://bugs.winehq.org/show_bug.cgi?id=1652 could be another manifestation of this bug.