Skip to content

Commit 3a4401a

Browse files
[Qt] Terminate string *pszExePath after readlink and without using memset
1 parent a90e6d2 commit 3a4401a

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
@@ -743,9 +743,10 @@ bool SetStartOnSystemStartup(bool fAutoStart)
743743
else
744744
{
745745
char pszExePath[MAX_PATH+1];
746-
memset(pszExePath, 0, sizeof(pszExePath));
747-
if (readlink("/proc/self/exe", pszExePath, sizeof(pszExePath)-1) == -1)
746+
ssize_t r = readlink("/proc/self/exe", pszExePath, sizeof(pszExePath) - 1);
747+
if (r == -1)
748748
return false;
749+
pszExePath[r] = '\0';
749750

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

0 commit comments

Comments
 (0)