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:
1 parent
9d9c4185fa
commit
e049fd76f0
1 file changed
+3
-2
+3
-2
@@ -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());
|
||||||
|
|||||||
Reference in new issue
Block a user