diff options
author | Kostya Serebryany <kcc@google.com> | 2016-10-15 04:00:07 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2016-10-15 04:00:07 +0000 |
commit | 9a4b10a56f8b3f7e8dc46cc48451836cd7fa6a9a (patch) | |
tree | 8efe3b022117dabda992e23bde2e43aafef4f740 /llvm/lib/Fuzzer/FuzzerTracePC.cpp | |
parent | 49db68d59b34351907f7f45d822919af099ed291 (diff) | |
download | bcm5719-llvm-9a4b10a56f8b3f7e8dc46cc48451836cd7fa6a9a.tar.gz bcm5719-llvm-9a4b10a56f8b3f7e8dc46cc48451836cd7fa6a9a.zip |
[libFuzzer] swap bytes in integers when handling CMP traces
llvm-svn: 284301
Diffstat (limited to 'llvm/lib/Fuzzer/FuzzerTracePC.cpp')
-rw-r--r-- | llvm/lib/Fuzzer/FuzzerTracePC.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerTracePC.cpp b/llvm/lib/Fuzzer/FuzzerTracePC.cpp index cfaf9c5e571..6b9e21068a2 100644 --- a/llvm/lib/Fuzzer/FuzzerTracePC.cpp +++ b/llvm/lib/Fuzzer/FuzzerTracePC.cpp @@ -208,22 +208,22 @@ void TracePC::TORCToDict(Dictionary *Dict, T FindInData, T Substitute, const size_t DataSize = sizeof(T); const uint8_t *End = Data + Size; int Attempts = 3; - // TODO: also swap bytes in FindInData. - for (const uint8_t *Cur = Data; Cur < End && Attempts--; Cur++) { - Cur = (uint8_t *)memmem(Cur, End - Cur, &FindInData, DataSize); - if (!Cur) - break; - size_t Pos = Cur - Data; - for (int Offset = 0; Offset <= 0; Offset++) { - T Tmp = Substitute + Offset; - Word W(reinterpret_cast<uint8_t *>(&Tmp), sizeof(Tmp)); + for (int DoSwap = 0; DoSwap <= 1; DoSwap++) { + for (const uint8_t *Cur = Data; Cur < End && Attempts--; Cur++) { + Cur = (uint8_t *)memmem(Cur, End - Cur, &FindInData, DataSize); + if (!Cur) + break; + size_t Pos = Cur - Data; + Word W(reinterpret_cast<uint8_t *>(&Substitute), sizeof(Substitute)); DictionaryEntry DE(W, Pos); // TODO: evict all entries from Dic if it's full. Dict->push_back(DE); // Printf("Dict[%zd] TORC%zd %llx => %llx pos %zd\n", Dict->size(), // sizeof(T), - // (uint64_t)FindInData, (uint64_t)Tmp, Pos); + // (uint64_t)FindInData, (uint64_t)Substitute, Pos); } + FindInData = Bswap(FindInData); + Substitute = Bswap(Substitute); } } |