diff options
| author | Luke Dashjr <[email protected]> | 2012-03-03 13:51:10 -0500 |
|---|---|---|
| committer | Luke Dashjr <[email protected]> | 2012-03-03 13:51:10 -0500 |
| commit | 88aa771536014919e955c4f7b2cada9a0dcf8561 (patch) | |
| tree | de3677fff44765e596b8cd8404a3959312acb6e8 /src/util.cpp | |
| parent | Bugfix: Check return value of SHGetSpecialFolderPath in MyGetSpecialFolderPath (diff) | |
| download | discoin-88aa771536014919e955c4f7b2cada9a0dcf8561.tar.xz discoin-88aa771536014919e955c4f7b2cada9a0dcf8561.zip | |
Bugfix: Fix possible buffer overflow (#901)
Upstream commit: 21ae37d (partial)
Diffstat (limited to 'src/util.cpp')
| -rw-r--r-- | src/util.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/util.cpp b/src/util.cpp index e2e104cc8..0f496bc45 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -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 |