aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2022-11-01 13:11:03 +0000
committerfanquake <fanquake@gmail.com>2022-11-01 13:31:40 +0000
commit067dc42b7995d823666292929c760f7dda602cb7 (patch)
treeac05bbf5f9e71044a718a9ae8929b3027f18a440 /src
parentc540f07ec3846b43f3af8a74820fd055ada5dfe5 (diff)
parente049fd76f0d57c1e6400fbfbaf4cc6ebe540f16f (diff)
downloadbitcoin-067dc42b7995d823666292929c760f7dda602cb7.tar.xz
Merge bitcoin/bitcoin#26434: [24.x] [gui] Bugfix: Check for readlink buffer overflow and handle gracefully
e049fd76f0d57c1e6400fbfbaf4cc6ebe540f16f Bugfix: Check for readlink buffer overflow and handle gracefully (Luke Dashjr) Pull request description: Identical commit taken as-is from https://github.com/bitcoin/bitcoin/pull/25548 for backport ACKs for top commit: hebasto: ACK e049fd76f0d57c1e6400fbfbaf4cc6ebe540f16f Tree-SHA512: 37e63d570de898187c1bc8dd311c299c527adea51faa08aa6a3923bdb9390e3263902ace3d52a1cfc34ac2ba84e9358961574f886be1f64b5749a62e3c50ad57
Diffstat (limited to 'src')
-rw-r--r--src/qt/guiutil.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp
index b9f0be41e3..6e88b57e08 100644
--- a/src/qt/guiutil.cpp
+++ b/src/qt/guiutil.cpp
@@ -615,9 +615,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());