Skip to content

Commit e049fd7

Browse files
committed
Bugfix: Check for readlink buffer overflow and handle gracefully
If readlink returns the size of the buffer, an overflow may have (safely) occurred. Pass a buffer size of MAX_PATH+1 (the size of the actual buffer) to detect this scenario.
1 parent 9d9c418 commit e049fd7

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-
ssize_t r = readlink("/proc/self/exe", pszExePath, sizeof(pszExePath) - 1);
747-
if (r == -1)
746+
ssize_t r = readlink("/proc/self/exe", pszExePath, sizeof(pszExePath));
747+
if (r == -1 || r > MAX_PATH) {
748748
return false;
749+
}
749750
pszExePath[r] = '\0';
750751

751752
fs::create_directories(GetAutostartDir());

0 commit comments

Comments
 (0)