This is an archive of the discontinued LLVM Phabricator instance.

Libfuzzer: do not pass null into user function
ClosedPublic

Authored by aizatsky on Nov 30 2015, 5:05 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

aizatsky updated this revision to Diff 41455.Nov 30 2015, 5:05 PM
aizatsky retitled this revision from to Libfuzzer: do not pass null into user function.
aizatsky updated this object.
aizatsky added a subscriber: llvm-commits.
krasin edited edge metadata.Nov 30 2015, 5:14 PM

LGTM with a nit

lib/Fuzzer/test/SimpleTest.cpp
11 ↗(On Diff #41455)

Alternatively, you could #include "gtest/gtest.h" and use EXPECT_NE:

EXPECT_NE(NULL, Data) << "Pointer to the data must not be NULL"

EXPECT_NE will work even if LLVM is built without asserts, while assert will just pass.

kcc added inline comments.Nov 30 2015, 5:46 PM
lib/Fuzzer/FuzzerLoop.cpp
242 ↗(On Diff #41455)

Looks weird.
I would prefer to have assert(!U.empty()) and enforce it in callers.

lib/Fuzzer/test/SimpleTest.cpp
11 ↗(On Diff #41455)

Oh no, we don't want these simple tests to depend on gtest.

aizatsky marked 2 inline comments as done.Dec 1 2015, 12:28 PM
aizatsky added inline comments.
lib/Fuzzer/FuzzerLoop.cpp
242 ↗(On Diff #41455)

There are too many paths that lead here. Plus, didn't we agree that its ok to call it with empty unit?

kcc added inline comments.Dec 2 2015, 2:27 PM
lib/Fuzzer/FuzzerLoop.cpp
242 ↗(On Diff #41455)

Emm. I am probably not 100% convinced we want to call this with empty units. But ok, let's assume we can.
Now, remind me, why we can't call the target function as f(NULL, 0) ?

kcc accepted this revision.Dec 2 2015, 2:30 PM
kcc edited edge metadata.

LGTM with two nits.

lib/Fuzzer/FuzzerLoop.cpp
242 ↗(On Diff #41455)

no static?

243 ↗(On Diff #41455)

no {} ?

This revision is now accepted and ready to land.Dec 2 2015, 2:30 PM
aizatsky updated this revision to Diff 41679.Dec 2 2015, 2:32 PM
aizatsky marked 2 inline comments as done.
aizatsky edited edge metadata.

review

thanks. running check-all and submitting.

This revision was automatically updated to reflect the committed changes.