Skip to content

Commit c5c77bd

Browse files
committed
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
2 parents 058c0f9 + 3a4401a commit c5c77bd

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/qt/guiutil.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -744,9 +744,10 @@ bool SetStartOnSystemStartup(bool fAutoStart)
744744
else
745745
{
746746
char pszExePath[MAX_PATH+1];
747-
memset(pszExePath, 0, sizeof(pszExePath));
748-
if (readlink("/proc/self/exe", pszExePath, sizeof(pszExePath)-1) == -1)
747+
ssize_t r = readlink("/proc/self/exe", pszExePath, sizeof(pszExePath) - 1);
748+
if (r == -1)
749749
return false;
750+
pszExePath[r] = '\0';
750751

751752
fs::create_directories(GetAutostartDir());
752753

0 commit comments

Comments
 (0)