diff --git a/afl_transforms/tools/zafl/zafl.cpp b/afl_transforms/tools/zafl/zafl.cpp index d69f3368529e346992f38022d4e38fa05c07ce7a..ebda0ec5379167f43212f8701a6d213af1058c27 100644 --- a/afl_transforms/tools/zafl/zafl.cpp +++ b/afl_transforms/tools/zafl/zafl.cpp @@ -455,10 +455,9 @@ void Zafl_t::insertForkServer(string p_forkServerEntry) if (std::isdigit(p_forkServerEntry[0])) { // find instruction to insert fork server based on address - const auto fileid = getFileIR()->GetFile()->GetBaseID(); const auto voffset = (virtual_offset_t) std::strtoul(p_forkServerEntry.c_str(), NULL, 16); auto instructions=find_if(getFileIR()->GetInstructions().begin(), getFileIR()->GetInstructions().end(), [&](const Instruction_t* i) { - return i->GetAddress()->GetFileID()==fileid && i->GetAddress()->GetVirtualOffset()==voffset; + return i->GetAddress()->GetVirtualOffset()==voffset; }); if (instructions==getFileIR()->GetInstructions().end()) diff --git a/test/gzip/test_gzip.sh b/test/gzip/test_gzip.sh index 56c47ac7df745d9736c619def92c4d014cf4a90b..ff5b34da758b1df5a1f9aaacc012bbd0a6a59434 100755 --- a/test/gzip/test_gzip.sh +++ b/test/gzip/test_gzip.sh @@ -62,6 +62,19 @@ test_zafl() pushd /tmp +# test setting of entry point via address +setup +ep=$( objdump -Mintel -d /bin/gzip | grep text | grep -v -i disassembly | cut -d' ' -f1 | sed 's/^00000000//g' ) +build_zafl gzip.stars.entrypoint.${ep}.zafl -o zafl:--stars -o "zafl:--entrypoint=$ep" +test_zafl ./gzip.stars.entrypoint.${ep}.zafl --fast +cleanup + +# test setting of entry point via function name +setup +build_zafl gzip.entrypoint.zafl -o "zafl:--entrypoint=main" +test_zafl ./gzip.entrypoint.zafl --slow +cleanup + # test STARS version setup build_zafl gzip.stars.zafl -o zafl:--stars @@ -78,6 +91,7 @@ test_zafl ./gzip.nostars.zafl --fast test_zafl ./gzip.nostars.zafl --best cleanup + log_success "all tests passed: zafl instrumentation operational on gzip" popd