Skip to content

Commit 5668cce

Browse files
committed
Merge bitcoin/bitcoin#25548: gui: Check for readlink buffer overflow and handle gracefully
e049fd7 Bugfix: Check for readlink buffer overflow and handle gracefully (Luke Dashjr) Pull request description: 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. ACKs for top commit: hebasto: ACK e049fd7. Tree-SHA512: 188bace79cbe556efe7782e46b870c02729b07b104a9316b0f7d50013504972e85baf507403d2d6060bb2bf3e13f40d735bddd18255d97a60810208c3de87691
2 parents c041d8f + e049fd7 commit 5668cce

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
@@ -615,9 +615,10 @@ bool SetStartOnSystemStartup(bool fAutoStart)
615615
else
616616
{
617617
char pszExePath[MAX_PATH+1];
618-
ssize_t r = readlink("/proc/self/exe", pszExePath, sizeof(pszExePath) - 1);
619-
if (r == -1)
618+
ssize_t r = readlink("/proc/self/exe", pszExePath, sizeof(pszExePath));
619+
if (r == -1 || r > MAX_PATH) {
620620
return false;
621+
}
621622
pszExePath[r] = '\0';
622623

623624
fs::create_directories(GetAutostartDir());

0 commit comments

Comments
 (0)