Page MenuHomePhabricator

[lldb] Fix out of bounds read in DataExtractor::GetCStr and add unit test that function.
ClosedPublic

Authored by teemperor on Oct 10 2019, 3:03 AM.

Details

Summary

The if (*cstr_end == '\0') in the previous code checked if the previous loop terminated because it
found a null terminator or because it reached the end of the data. However, in the case that we hit
the end of the data before finding a null terminator, cstr_end points behind the last byte in our
data and *cstr_end reads the memory behind the array (which may be uninitialised)

This patch just rewrites that function use std::find and adds the relevant unit tests.

Diff Detail

Event Timeline

teemperor created this revision.Oct 10 2019, 3:03 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 10 2019, 3:03 AM
labath accepted this revision.Oct 10 2019, 3:53 AM
This revision is now accepted and ready to land.Oct 10 2019, 3:53 AM
teemperor retitled this revision from [lldb] Fix out of bounds read in DataExtractor::GetCStr and add actually unit test that function. to [lldb] Fix out of bounds read in DataExtractor::GetCStr and add unit test that function..Oct 10 2019, 4:12 AM
This revision was automatically updated to reflect the committed changes.