diff options
| author | Wladimir J. van der Laan <[email protected]> | 2017-10-02 15:04:21 +0200 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2017-10-02 15:04:43 +0200 |
| commit | c5c77bdcc632997dbd1b7633c2f3f3505cd864df (patch) | |
| tree | 5eec0cd8316324db7cc43c84460afa06cfece615 /src/qt/guiutil.cpp | |
| parent | Merge #11432: Remove unused fTry from push_lock (diff) | |
| parent | [Qt] Terminate string *pszExePath after readlink and without using memset (diff) | |
| download | discoin-c5c77bdcc632997dbd1b7633c2f3f3505cd864df.tar.xz discoin-c5c77bdcc632997dbd1b7633c2f3f3505cd864df.zip | |
Merge #11193: [Qt] Terminate string *pszExePath after readlink and without using memset
3a4401a [Qt] Terminate string *pszExePath after readlink and without using memset (practicalswift)
Pull request description:
Terminate string `*pszExePath` after `readlink` and before passing to operator `<<`.
* `ssize_t readlink(const char *pathname, char *buf, size_t bufsiz)` does not append a null byte to `buf`.
* Operator `<<` expects a null-terminated string.
Tree-SHA512: fc18844bb23059fead8db0cb9b4b4ba6188f58e3f19ab4719c2737cc5dd6df23ae7d4804ef2820d39b334204a48ee3de1d202c272bcd156e60761af2fcb9349d
Diffstat (limited to 'src/qt/guiutil.cpp')
| -rw-r--r-- | src/qt/guiutil.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index b916df69a..d520d7d4b 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -744,9 +744,10 @@ bool SetStartOnSystemStartup(bool fAutoStart) else { char pszExePath[MAX_PATH+1]; - memset(pszExePath, 0, sizeof(pszExePath)); - if (readlink("/proc/self/exe", pszExePath, sizeof(pszExePath)-1) == -1) + ssize_t r = readlink("/proc/self/exe", pszExePath, sizeof(pszExePath) - 1); + if (r == -1) return false; + pszExePath[r] = '\0'; fs::create_directories(GetAutostartDir()); |