diff options
| author | Luke Dashjr <[email protected]> | 2012-03-03 13:59:19 -0500 |
|---|---|---|
| committer | Luke Dashjr <[email protected]> | 2012-03-03 13:59:19 -0500 |
| commit | 7013cc3d9710c0a03f6587c854e4e50c358ea70c (patch) | |
| tree | 35e3c2ff533126be6d8d495eb6cf33d62b609014 /src/util.cpp | |
| parent | In UI, handle cases in which the last received block was generated in the fut... (diff) | |
| parent | Bugfix: Fix possible buffer overflow (#901) (diff) | |
| download | discoin-7013cc3d9710c0a03f6587c854e4e50c358ea70c.tar.xz discoin-7013cc3d9710c0a03f6587c854e4e50c358ea70c.zip | |
Merge branch '0.4.x' into 0.5.0.x
Diffstat (limited to 'src/util.cpp')
| -rw-r--r-- | src/util.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/util.cpp b/src/util.cpp index b17166a0e..f6c37a2d1 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -737,26 +737,35 @@ string MyGetSpecialFolderPath(int nFolder, bool fCreate) { PSHGETSPECIALFOLDERPATHA pSHGetSpecialFolderPath = (PSHGETSPECIALFOLDERPATHA)GetProcAddress(hShell32, "SHGetSpecialFolderPathA"); + bool fSuccess = false; if (pSHGetSpecialFolderPath) + fSuccess = (*pSHGetSpecialFolderPath)(NULL, pszPath, nFolder, fCreate); FreeModule(hShell32); + if (fSuccess) + return pszPath; } // Backup option - if (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 |