| Index: src/processor/exploitability_linux.cc
|
| diff --git a/src/processor/exploitability_linux.cc b/src/processor/exploitability_linux.cc
|
| index a196da79ab78ea204714c11c9ea5efd30cc0fa20..8c1e502e43da0e53e3ee55895123dc76a704e33e 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,32 @@ bool ExploitabilityLinux::CalculateAddress(const string &address_expression,
|
| return true;
|
| }
|
|
|
| +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)) {
|
| + BPLOG(INFO) << "Objdump instructions not found";
|
| + return false;
|
| + }
|
| + if (instruction_line->find("<.data>:") != string::npos) {
|
| + data_section_seen = true;
|
| + }
|
| + } 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,
|
|
|