| OLD | NEW |
| 1 // Copyright (c) 2010, Google Inc. | 1 // Copyright (c) 2010, Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 ASSERT_FALSE(ExploitabilityLinuxTest::DisassembleBytes("", NULL, 5, NULL)); | 187 ASSERT_FALSE(ExploitabilityLinuxTest::DisassembleBytes("", NULL, 5, NULL)); |
| 188 uint8_t bytes[6] = {0xc7, 0x0, 0x5, 0x0, 0x0, 0x0}; | 188 uint8_t bytes[6] = {0xc7, 0x0, 0x5, 0x0, 0x0, 0x0}; |
| 189 char buffer[1024] = {0}; | 189 char buffer[1024] = {0}; |
| 190 ASSERT_TRUE(ExploitabilityLinuxTest::DisassembleBytes("i386:x86-64", | 190 ASSERT_TRUE(ExploitabilityLinuxTest::DisassembleBytes("i386:x86-64", |
| 191 bytes, | 191 bytes, |
| 192 1024, | 192 1024, |
| 193 buffer)); | 193 buffer)); |
| 194 std::stringstream objdump_stream; | 194 std::stringstream objdump_stream; |
| 195 objdump_stream.str(string(buffer)); | 195 objdump_stream.str(string(buffer)); |
| 196 string line = ""; | 196 string line = ""; |
| 197 while ((line.find("0:") == string::npos) && getline(objdump_stream, line)) { | 197 while ((line.find("<.data>") == string::npos) && |
| 198 getline(objdump_stream, line)) { |
| 198 } | 199 } |
| 200 ASSERT_TRUE(getline(objdump_stream, line)); |
| 199 ASSERT_EQ(line, " 0:\tc7 00 05 00 00 00 \tmov DWORD PTR [rax],0x5"); | 201 ASSERT_EQ(line, " 0:\tc7 00 05 00 00 00 \tmov DWORD PTR [rax],0x5"); |
| 200 } | 202 } |
| 201 | 203 |
| 202 TEST(ExploitabilityLinuxUtilsTest, TokenizeObjdumpInstructionTest) { | 204 TEST(ExploitabilityLinuxUtilsTest, TokenizeObjdumpInstructionTest) { |
| 203 ASSERT_FALSE(ExploitabilityLinuxTest::TokenizeObjdumpInstruction("", | 205 ASSERT_FALSE(ExploitabilityLinuxTest::TokenizeObjdumpInstruction("", |
| 204 NULL, | 206 NULL, |
| 205 NULL, | 207 NULL, |
| 206 NULL)); | 208 NULL)); |
| 207 string line = "0: c7 00 05 00 00 00 mov DWORD PTR [rax],0x5"; | 209 string line = "0: c7 00 05 00 00 00 mov DWORD PTR [rax],0x5"; |
| 208 string operation = ""; | 210 string operation = ""; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 ASSERT_FALSE(ExploitabilityLinuxTest::CalculateAddress("rdx+rax", | 253 ASSERT_FALSE(ExploitabilityLinuxTest::CalculateAddress("rdx+rax", |
| 252 context, | 254 context, |
| 253 &write_address)); | 255 &write_address)); |
| 254 ASSERT_FALSE(ExploitabilityLinuxTest::CalculateAddress("0x3482+0x4D2", | 256 ASSERT_FALSE(ExploitabilityLinuxTest::CalculateAddress("0x3482+0x4D2", |
| 255 context, | 257 context, |
| 256 &write_address)); | 258 &write_address)); |
| 257 } | 259 } |
| 258 #endif // _WIN32 | 260 #endif // _WIN32 |
| 259 | 261 |
| 260 } // namespace | 262 } // namespace |
| OLD | NEW |