Chromium Code Reviews| Index: src/processor/exploitability_linux.cc |
| diff --git a/src/processor/exploitability_linux.cc b/src/processor/exploitability_linux.cc |
| index a196da79ab78ea204714c11c9ea5efd30cc0fa20..c520059c10b2d386ffd48ac7a42432e82eba6da5 100644 |
| --- a/src/processor/exploitability_linux.cc |
| +++ b/src/processor/exploitability_linux.cc |
| @@ -231,21 +231,10 @@ bool ExploitabilityLinux::EndedOnIllegalWrite(uint64_t instruction_ptr) { |
| MAX_OBJDUMP_BUFFER_LEN, |
| objdump_output_buffer); |
| - // Put buffer data into stream to output line-by-line. |
| - std::stringstream objdump_stream; |
| - objdump_stream.str(string(objdump_output_buffer)); |
| string line; |
| - |
| - // Pipe each output line into the string until the string contains |
| - // the first instruction from objdump. |
| - // Loop until the line shows the first instruction or there are no lines left. |
| - do { |
| - if (!getline(objdump_stream, line)) { |
| - BPLOG(INFO) << "Objdump instructions not found"; |
| - return false; |
| - } |
| - } while (line.find("0:") == string::npos); |
| - // This first instruction contains the above substring. |
| + if (!GetObjdumpInstructionLine(objdump_output_buffer, &line)) { |
| + return false; |
| + } |
| // Convert objdump instruction line into the operation and operands. |
| string instruction = ""; |
| @@ -399,6 +388,33 @@ bool ExploitabilityLinux::CalculateAddress(const string &address_expression, |
| return true; |
| } |
| +// static |
| +bool ExploitabilityLinux::GetObjdumpInstructionLine( |
| + const char *objdump_output_buffer, |
| + string *instruction_line) { |
| + // Put buffer data into stream to output line-by-line. |
| + std::stringstream objdump_stream; |
| + objdump_stream.str(string(objdump_output_buffer)); |
| + |
| + // Pipe each output line into the string until the string contains the first |
| + // instruction from objdump. All lines before the "<.data>:" section are |
| + // skipped. Loop until the line shows the first instruction or there are no |
| + // lines left. |
| + bool data_section_seen = false; |
| + do { |
| + if (!getline(objdump_stream, *instruction_line)) { |
|
Mark Mentovai
2016/02/17 02:24:18
std::getline
ivanpe
2016/02/17 06:27:41
I'll handle this in a new CL.
|
| + BPLOG(INFO) << "Objdump instructions not found"; |
| + return false; |
| + } |
| + if (instruction_line->find("<.data>:") != string::npos) { |
| + data_section_seen = true; |
| + } |
|
Mark Mentovai
2016/02/17 02:24:18
At some point after seeing <.data>:, if you enter
ivanpe
2016/02/17 06:27:41
Here, we are parsing the output of objdump. objdu
|
| + } while (!data_section_seen || instruction_line->find("0:") == string::npos); |
| + // This first instruction contains the above substring. |
| + |
| + return true; |
| +} |
| + |
| bool ExploitabilityLinux::TokenizeObjdumpInstruction(const string &line, |
| string *operation, |
| string *dest, |