Skip to content

targets.txt is empty when compiling tiffcrop.bc with CBI instrumentation #2

@zchengchen

Description

@zchengchen

While following the procedure for the tiffcrop issue (#488, BIC: 7057734d, BFC: 97d65859), I encountered a problem during fuzzing. Below are the steps I followed:

git clone https://gitlab.com/libtiff/libtiff.git /home/waflgo-libtiff
cd /home/waflgo-libtiff; git checkout 07d79fcac

export ADD="-g --notI "
export CC=/home/WAFLGo/afl-clang-fast CXX=/home/WAFLGo/afl-clang-fast++  CFLAGS="$ADD" CXXFLAGS="$ADD"
export AFL_CC=gclang AFL_CXX=gclang++

cmake . 
make clean;make -j $(nproc) 
unset AFL_CC AFL_CXX

# ** Get bitcode file from executable file

cp ./tools/tiffcrop ./
get-bc tiffcrop

# ** Set the target site

mkdir fuzz; cd fuzz
cp ../tiffcrop.bc .

echo $'' > $TMP_DIR/BBtargets.txt
git diff HEAD^1 HEAD > ./commit.diff
cp /home/showlinenum.awk ./
sed -i -e 's/\r$//' showlinenum.awk
chmod +x showlinenum.awk
cat ./commit.diff |  ./showlinenum.awk show_header=0 path=1 | grep -e "\.[ch]:[0-9]*:+" -e "\.cpp:[0-9]*:+" -e "\.cc:[0-9]*:+" | cut -d+ -f1 | rev | cut -c2- | rev > ./targets

# cat ./targets

# ** Instrument

/home/WAFLGo/instrument/bin/cbi --targets=targets tiffcrop.bc --stats=false
cp ./targets_id.txt /home
cp ./suffix.txt /home
cp ./targets*.txt /home
cp ./distance.txt /home
cp ./branch-distance.txt /home
cp ./branch-distance-min.txt /home
cp ./branch-curloc.txt /home
cp ./*_data.txt /home

# ** Compile bitcode file to executable file which is used to be fuzzed

/home/WAFLGo/afl-clang-fast++ tiffcrop.ci.bc  -lstdc++ -ltiff -o tiffcrop.ci
cp ./bbinfo-fast.txt /home/bbinfo-ci-bc.txt
cp ./branch-distance-order.txt /home
cp ./*-distance-order.txt /home
cp ./*-order.txt /home

/home/WAFLGo/afl-fuzz  -T waflgo-libtiff -t 1000+ -m none -z exp -c 45m -q 1 -i /home/jpg -o /home/out -- /home/waflgo-libtiff/fuzz/[tiffcrop.ci](http://tiffcrop.ci/)  @@

However, when running afl-fuzz, I received the following message:
Image

[afl++ 5ee78209c115] /home/waflgo-libtiff/fuzz ((07d79fca...)) # cat targets.txt
[afl++ 5ee78209c115] /home/waflgo-libtiff/fuzz ((07d79fca...)) # 

Using the WAFLGo Docker image provided on GitHub.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions