mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 10:43:19 -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
|
else
|
||||||
{
|
{
|
||||||
char pszExePath[MAX_PATH+1];
|
char pszExePath[MAX_PATH+1];
|
||||||
ssize_t r = readlink("/proc/self/exe", pszExePath, sizeof(pszExePath) - 1);
|
ssize_t r = readlink("/proc/self/exe", pszExePath, sizeof(pszExePath));
|
||||||
if (r == -1)
|
if (r == -1 || r > MAX_PATH) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
pszExePath[r] = '\0';
|
pszExePath[r] = '\0';
|
||||||
|
|
||||||
fs::create_directories(GetAutostartDir());
|
fs::create_directories(GetAutostartDir());
|
||||||
|
|
Loading…
Add table
Reference in a new issue