[llvm] r281111 - [libFuzzer] use sizeof() in tests instead of 4 and 8
Kostya Serebryany via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 9 15:21:16 PDT 2016
Author: kcc
Date: Fri Sep 9 17:21:16 2016
New Revision: 281111
URL: http://llvm.org/viewvc/llvm-project?rev=281111&view=rev
Log:
[libFuzzer] use sizeof() in tests instead of 4 and 8
Modified:
llvm/trunk/lib/Fuzzer/test/AbsNegAndConstant64Test.cpp
llvm/trunk/lib/Fuzzer/test/AbsNegAndConstantTest.cpp
Modified: llvm/trunk/lib/Fuzzer/test/AbsNegAndConstant64Test.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/test/AbsNegAndConstant64Test.cpp?rev=281111&r1=281110&r2=281111&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/test/AbsNegAndConstant64Test.cpp (original)
+++ llvm/trunk/lib/Fuzzer/test/AbsNegAndConstant64Test.cpp Fri Sep 9 17:21:16 2016
@@ -10,10 +10,10 @@
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
if (Size < 16) return 0;
- long x;
- unsigned long y;
- memcpy(&x, Data, 8);
- memcpy(&y, Data + 8, 8);
+ int64_t x;
+ uint64_t y;
+ memcpy(&x, Data, sizeof(x));
+ memcpy(&y, Data + sizeof(x), sizeof(y));
if (labs(x) < 0 && y == 0xbaddcafedeadbeefUL) {
printf("BINGO; Found the target, exiting; x = 0x%lx y 0x%lx\n", x, y);
exit(1);
Modified: llvm/trunk/lib/Fuzzer/test/AbsNegAndConstantTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/test/AbsNegAndConstantTest.cpp?rev=281111&r1=281110&r2=281111&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/test/AbsNegAndConstantTest.cpp (original)
+++ llvm/trunk/lib/Fuzzer/test/AbsNegAndConstantTest.cpp Fri Sep 9 17:21:16 2016
@@ -12,8 +12,8 @@ extern "C" int LLVMFuzzerTestOneInput(co
if (Size < 8) return 0;
int x;
unsigned y;
- memcpy(&x, Data, 4);
- memcpy(&y, Data + 4, 4);
+ memcpy(&x, Data, sizeof(x));
+ memcpy(&y, Data + sizeof(x), sizeof(y));
if (abs(x) < 0 && y == 0xbaddcafe) {
printf("BINGO; Found the target, exiting; x = 0x%x y 0x%x\n", x, y);
exit(1);
More information about the llvm-commits
mailing list