Commit 203b72c2 authored by Loïc Yhuel's avatar Loïc Yhuel Committed by Arjen Hiemstra
Browse files

Fix incorrect string termination in ConnectionMapping

After readlinkat, the nul character is not written at the correct index.
When readlinkat truncates the result, the code writes after the end of the array, which
triggers an assert in libstdc++.
In the other cases, it leaves an uninitialized char 'u' at the end of the array, but the
code stops at the ']' of "socket:[...]u".


(cherry picked from commit 6a60a626)
parent 4d1052c1
......@@ -225,7 +225,7 @@ void ConnectionMapping::parsePid()
// /proc/PID/fd contains symlinks for each open fd in the process.
// The symlink target contains information about what the fd is about.
auto size = readlinkat(dirfd(fdDir), fd->d_name, buffer.data(), 99);
buffer[size + 1] = '\0';
buffer[size] = '\0';
auto view = std::string_view(buffer.data(), 100);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment