Skip to content

Commit

Permalink
Merge #11193: [Qt] Terminate string *pszExePath after readlink and wi…
Browse files Browse the repository at this point in the history
…thout using memset

Summary:
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

Backport of Core PR11193
bitcoin/bitcoin#11193

Test Plan:
  make check
  ./bitcoin-qt

Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Reviewed By: Fabien, O1 Bitcoin ABC, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D3933
  • Loading branch information
laanwj authored and jonspock committed Dec 8, 2019
1 parent 83b75f3 commit 53b091f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/qt/guiutil.cpp
Expand Up @@ -739,11 +739,12 @@ bool SetStartOnSystemStartup(bool fAutoStart) {
fs::remove(GetAutostartFilePath());
} 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());

Expand Down

0 comments on commit 53b091f

Please sign in to comment.