[PATCH] D15098: Libfuzzer: do not pass null into user function
Mike Aizatsky via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 2 14:47:00 PST 2015
This revision was automatically updated to reflect the committed changes.
Closed by commit rL254558: Libfuzzer: do not pass null into user function (authored by aizatsky).
Changed prior to commit:
http://reviews.llvm.org/D15098?vs=41679&id=41682#toc
Repository:
rL LLVM
http://reviews.llvm.org/D15098
Files:
llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp
llvm/trunk/lib/Fuzzer/test/SimpleTest.cpp
Index: llvm/trunk/lib/Fuzzer/test/SimpleTest.cpp
===================================================================
--- llvm/trunk/lib/Fuzzer/test/SimpleTest.cpp
+++ llvm/trunk/lib/Fuzzer/test/SimpleTest.cpp
@@ -1,12 +1,14 @@
// Simple test for a fuzzer. The fuzzer must find the string "Hi!".
+#include <assert.h>
#include <cstdint>
#include <cstdlib>
#include <cstddef>
#include <iostream>
static volatile int Sink;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+ assert(Data);
if (Size > 0 && Data[0] == 'H') {
Sink = 1;
if (Size > 1 && Data[1] == 'i') {
Index: llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp
===================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp
+++ llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp
@@ -238,7 +238,11 @@
}
void Fuzzer::ExecuteCallback(const Unit &U) {
- int Res = USF.TargetFunction(U.data(), U.size());
+ const uint8_t *Data = U.data();
+ uint8_t EmptyData;
+ if (!Data)
+ Data = &EmptyData;
+ int Res = USF.TargetFunction(Data, U.size());
(void)Res;
assert(Res == 0);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15098.41682.patch
Type: text/x-patch
Size: 1115 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151202/e7ac7650/attachment.bin>
More information about the llvm-commits
mailing list