Check-in [05a7ef3fae]
Overview
Comment:Added AFL test script
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:05a7ef3faeab86e29c4f0584659de974d4e77e4d
User & Date: rkeene on 2020-03-31 18:46:11
Other Links: manifest | tags
Context
2020-03-31
18:50
Ensure wiki update happens on the correct directory check-in: f901bb8bfd user: rkeene tags: trunk
18:46
Added AFL test script check-in: 05a7ef3fae user: rkeene tags: trunk
14:30
Integrated remove-c11-atomics changes check-in: 7ee2e833d2 user: rkeene tags: trunk
Changes

Added build/test-afl version [fd2b240781].

            1  +#! /usr/bin/env bash
            2  +
            3  +PATH="/opt/appfs/rkeene.org/afl/platform/latest/bin:${PATH:-/dev/null/null}"
            4  +export PATH
            5  +
            6  +set -e
            7  +
            8  +sourcedir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
            9  +
           10  +workdir=''
           11  +inputdir=''
           12  +outputdir=''
           13  +function cleanup() {
           14  +	cd /
           15  +	if [ -n "${outputdir}" -a -d "${outputdir}" ]; then
           16  +		cp -rp "${outputdir}" "${sourcedir}/build/afl-$(uname -n | cut -f 1 -d .)-$(stat -c %Y "${outputdir}")"
           17  +	fi
           18  +
           19  +	if [ -n "${workdir}" ]; then
           20  +		rm -rf "${workdir}"
           21  +		workdir=''
           22  +	fi
           23  +}
           24  +trap cleanup EXIT
           25  +
           26  +workdir="$(mktemp -d)"
           27  +inputdir="${workdir}/input"
           28  +outputdir="${workdir}/output"
           29  +mkdir "${workdir}/src"
           30  +
           31  +cp -r "${sourcedir}"/* "${workdir}/src/"
           32  +
           33  +(
           34  +	set -e
           35  +
           36  +	cd "${workdir}"
           37  +	mkdir "${inputdir}" "${outputdir}"
           38  +
           39  +	echo $'GET /etc/passwd HTTP/1.1\x0d\x0aHost: example.com\x0d\x0a\x0d\x0a' > input/test-1
           40  +
           41  +	cd 'src'
           42  +	make distclean
           43  +	make CC=afl-gcc FILED_EXTRA_CFLAGS=-DFILED_TEST_AFL=1
           44  +
           45  +	#export AFL_SKIP_CPUFREQ=1
           46  +	afl-fuzz -i "${inputdir}" -o "${outputdir}" -- ./filed
           47  +)
           48  +
           49  +exit 0

Modified filed.c from [7252b16239] to [eba3a486d8].

    56     56   #define BIND_ADDR "::"
    57     57   #define CACHE_SIZE 8209
    58     58   #define LOG_FILE "-"
    59     59   
    60     60   /* Fuzzing Test Code */
    61     61   #ifdef FILED_TEST_AFL
    62     62   #define FILED_DONT_LOG 1
           63  +#define FILED_DONT_TIMEOUT 1
    63     64   #define pthread_create(a, x, y, z) afl_pthread_create(a, x, y, z)
    64     65   #define bind(x, y, z) afl_bind(x, y, z)
    65     66   #define socket(x, y, z) 8193
    66     67   #define listen(x, y) 0
    67     68   #define accept(x, y, z) afl_accept(x, y, z)
    68     69   #define close(x) { if (strcmp(#x, "random_fd") == 0) { close(x); } else { exit(0); } }
    69     70   #define fclose(x) exit(0)