Bugfix: Fix possible buffer overflow (#901)

Upstream commit: 21ae37d (partial)
This commit is contained in:
Luke Dashjr 2012-03-03 13:51:10 -05:00
parent 4fc8c042a2
commit 88aa771536

View File

@ -653,20 +653,25 @@ string MyGetSpecialFolderPath(int nFolder, bool fCreate)
}
// Backup option
pszPath[0] = '\0';
std::string strPath;
{
const char *pszEnv;
if (nFolder == CSIDL_STARTUP)
{
strcpy(pszPath, getenv("USERPROFILE"));
strcat(pszPath, "\\Start Menu\\Programs\\Startup");
pszEnv = getenv("USERPROFILE");
if (pszEnv)
strPath = pszEnv;
strPath += "\\Start Menu\\Programs\\Startup";
}
else if (nFolder == CSIDL_APPDATA)
{
strcpy(pszPath, getenv("APPDATA"));
pszEnv = getenv("APPDATA");
if (pszEnv)
strPath = pszEnv;
}
}
return pszPath;
return strPath;
}
#endif