[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:32:33 PST 2015
aizatsky updated this revision to Diff 41679.
aizatsky marked 2 inline comments as done.
aizatsky added a comment.
review
http://reviews.llvm.org/D15098
Files:
lib/Fuzzer/FuzzerLoop.cpp
lib/Fuzzer/test/SimpleTest.cpp
Index: lib/Fuzzer/test/SimpleTest.cpp
===================================================================
--- lib/Fuzzer/test/SimpleTest.cpp
+++ 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: lib/Fuzzer/FuzzerLoop.cpp
===================================================================
--- lib/Fuzzer/FuzzerLoop.cpp
+++ 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.41679.patch
Type: text/x-patch
Size: 1049 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151202/80325a0e/attachment.bin>
More information about the llvm-commits
mailing list