Skip to content
Snippets Groups Projects
Commit 862562ce authored by Matthias Männich's avatar Matthias Männich
Browse files

SystemInformation: fix potential off-by-one write

in case readlink uses the complete buffer (1024) it will truncate the
result and return 1024 assigned to ll. the subsequent buf[ll] will then be
out of bounds.

the fix assumes, that a truncated result is as useful as experiencing an
error during readlink, hence falling back to /proc/self/exe.
parent e75d1a31
No related branches found
No related tags found
No related merge requests found
...@@ -1346,7 +1346,7 @@ std::string SymbolProperties::GetBinary() const ...@@ -1346,7 +1346,7 @@ std::string SymbolProperties::GetBinary() const
std::string binary; std::string binary;
char buf[1024] = { '\0' }; char buf[1024] = { '\0' };
ssize_t ll = 0; ssize_t ll = 0;
if ((ll = readlink("/proc/self/exe", buf, 1024)) > 0) { if ((ll = readlink("/proc/self/exe", buf, 1024)) > 0 && ll < 1024) {
buf[ll] = '\0'; buf[ll] = '\0';
binary = buf; binary = buf;
} else { } else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment