This is an archive of the discontinued LLVM Phabricator instance.

[fuzzer] Read files as binary
ClosedPublic

Authored by metzman on Nov 6 2018, 1:14 PM.

Diff Detail

Event Timeline

metzman created this revision.Nov 6 2018, 1:14 PM
metzman updated this revision to Diff 172838.Nov 6 2018, 1:20 PM
  • Fix binary issue afl_driver

Please take a look

This should fix crbug.com/902460

I didn't change the uses of ifstream in FuzzerDataFlowTrace.cpp and FuzzerMerge.cpp since they seem to be used on nonbinary files written by libFuzzer.

compiler-rt/lib/fuzzer/FuzzerIO.cpp
54 ↗(On Diff #172837)

I don't think it is 100% necessary to use binary for this line, but probably better safe than sorry.

Dor1s added a comment.Nov 6 2018, 1:55 PM

I guess it might be worth adding the binary mode argument to FuzzerMerge.cpp and FuzzerDataFlowTrace.cpp as well, since apparently we may have some unexpected platform-dependent specifics when reading files.

Is there a test for this that fails on Windows?

metzman added a comment.EditedNov 6 2018, 2:03 PM

I guess it might be worth adding the binary mode argument to FuzzerMerge.cpp and FuzzerDataFlowTrace.cpp as well, since apparently we may have some unexpected platform-dependent specifics when reading files.

Do you think those files can contain binary? They look like they cannot to me.

Is there a test for this that fails on Windows?

Do you mean a test for this behavior that passes on Windows?

metzman updated this revision to Diff 172858.Nov 6 2018, 2:53 PM
  • Add test
Dor1s accepted this revision.Nov 6 2018, 3:01 PM

LGTM!

This revision is now accepted and ready to land.Nov 6 2018, 3:01 PM
metzman updated this revision to Diff 172859.Nov 6 2018, 3:03 PM
  • Use echo instead of printf

@morehouse I added a test for this. Please take another look.

metzman updated this revision to Diff 172868.Nov 6 2018, 3:23 PM
  • fix comment
This revision was automatically updated to reflect the committed changes.
Herald added subscribers: Restricted Project, llvm-commits. · View Herald TranscriptNov 6 2018, 3:27 PM