Skip to content

Commit

Permalink
Merge bitcoin#11193: [Qt] Terminate string *pszExePath after readlink…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
laanwj authored and PastaPastaPasta committed Jan 22, 2020
1 parent 89831ef commit b26a3b8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/qt/guiutil.cpp
Expand Up @@ -814,9 +814,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());

Expand Down

0 comments on commit b26a3b8

Please sign in to comment.