mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 20:03:34 -03:00
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.
This commit is contained in:
parent
9d9c4185fa
commit
e049fd76f0
1 changed files with 3 additions and 2 deletions
|
@ -743,9 +743,10 @@ bool SetStartOnSystemStartup(bool fAutoStart)
|
|||
else
|
||||
{
|
||||
char pszExePath[MAX_PATH+1];
|
||||
ssize_t r = readlink("/proc/self/exe", pszExePath, sizeof(pszExePath) - 1);
|
||||
if (r == -1)
|
||||
ssize_t r = readlink("/proc/self/exe", pszExePath, sizeof(pszExePath));
|
||||
if (r == -1 || r > MAX_PATH) {
|
||||
return false;
|
||||
}
|
||||
pszExePath[r] = '\0';
|
||||
|
||||
fs::create_directories(GetAutostartDir());
|
||||
|
|
Loading…
Reference in a new issue