[lldb][Linux] Fix potential out of bounds read of pr_fname #159375
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#157170 added code that assigned pr_fname to another std::string member.
In the lines before, we copy pr_fname using assign with a max length set to either the length of the string in pr_fname, or the size of pr_fname. Which is 16 bytes.
struct ELFLinuxPrPsInfo {
<...>
char pr_fname[16];
The content of pr_fname can fill all 16 bytes, that's why we need the limit.
This was not done for m_executable_name where it ended up calling the assignment from char* operator which could read on into the rest of the corefile in some cases.
Likely wouldn't crash for reading out of bounds, but you would at least see some strange things in LLDB.
Fix this by copying the std::string we already made for thread_data.name.