Enhance fuzzing
This commit is contained in:
parent
e8f083e867
commit
896a5e299a
|
@ -9,6 +9,10 @@ are taken from the $NAME.in directory.
|
||||||
Crash reproducers from OSS-Fuzz are put into $NAME.repro directory for
|
Crash reproducers from OSS-Fuzz are put into $NAME.repro directory for
|
||||||
regression testing with top dir 'make check' or 'make check-valgrind'.
|
regression testing with top dir 'make check' or 'make check-valgrind'.
|
||||||
|
|
||||||
|
The ./configure runs below are for libidn2.
|
||||||
|
To test libicu replace 'libidn2' with 'libicu', to test with
|
||||||
|
libidn replace 'libidn2' by 'libidn'.
|
||||||
|
|
||||||
|
|
||||||
# Running a fuzzer using clang
|
# Running a fuzzer using clang
|
||||||
|
|
||||||
|
@ -33,7 +37,7 @@ cd fuzz
|
||||||
Use the following commands on top dir:
|
Use the following commands on top dir:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ CC=afl-clang-fast ./configure --disable-gtk-doc
|
$ CC=afl-clang-fast ./configure --disable-gtk-doc --enable-runtime=libidn2 --enable-builtin=libidn2
|
||||||
$ make -j$(nproc) clean all
|
$ make -j$(nproc) clean all
|
||||||
$ cd fuzz
|
$ cd fuzz
|
||||||
$ ./run-afl.sh libpsl_fuzzer
|
$ ./run-afl.sh libpsl_fuzzer
|
||||||
|
@ -45,7 +49,7 @@ Code coverage reports currently work best with gcc+lcov+genhtml.
|
||||||
|
|
||||||
In the top directory:
|
In the top directory:
|
||||||
```
|
```
|
||||||
CC=gcc CFLAGS="-O0 -g" ./configure --disable-gtk-doc
|
CC=gcc CFLAGS="-O0 -g" ./configure --disable-gtk-doc --enable-runtime=libidn2 --enable-builtin=libidn2
|
||||||
make fuzz-coverage
|
make fuzz-coverage
|
||||||
xdg-open lcov/index.html
|
xdg-open lcov/index.html
|
||||||
```
|
```
|
||||||
|
|
|
@ -50,15 +50,29 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||||
psl_is_public_suffix(psl, domain);
|
psl_is_public_suffix(psl, domain);
|
||||||
psl_is_public_suffix2(psl, domain, PSL_TYPE_PRIVATE);
|
psl_is_public_suffix2(psl, domain, PSL_TYPE_PRIVATE);
|
||||||
psl_is_public_suffix2(psl, domain, PSL_TYPE_ICANN);
|
psl_is_public_suffix2(psl, domain, PSL_TYPE_ICANN);
|
||||||
|
psl_unregistrable_domain(psl, domain);
|
||||||
|
psl_registrable_domain(psl, domain);
|
||||||
|
|
||||||
psl_is_cookie_domain_acceptable(psl, "", NULL);
|
psl_is_cookie_domain_acceptable(psl, "", NULL);
|
||||||
psl_is_cookie_domain_acceptable(psl, "a.b.c.e.com", domain);
|
psl_is_cookie_domain_acceptable(psl, "a.b.c.e.com", domain);
|
||||||
|
|
||||||
if ((rc = psl_str_to_utf8lower(domain, "utf-8", NULL, &res)) == PSL_SUCCESS)
|
if ((rc = psl_str_to_utf8lower(domain, "utf-8", NULL, &res)) == PSL_SUCCESS)
|
||||||
free(res);
|
free(res);
|
||||||
|
if ((rc = psl_str_to_utf8lower(domain, "iso-8859-1", NULL, &res)) == PSL_SUCCESS)
|
||||||
|
free(res);
|
||||||
|
if ((rc = psl_str_to_utf8lower(domain, NULL, NULL, &res)) == PSL_SUCCESS)
|
||||||
|
free(res);
|
||||||
|
|
||||||
psl_free(psl);
|
psl_free(psl);
|
||||||
|
|
||||||
|
psl_check_version_number(1);
|
||||||
|
psl_get_version();
|
||||||
|
psl_dist_filename();
|
||||||
|
psl_builtin_outdated();
|
||||||
|
psl_builtin_filename();
|
||||||
|
psl_builtin_sha1sum();
|
||||||
|
psl_builtin_file_time();
|
||||||
|
|
||||||
free(domain);
|
free(domain);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
x.com
|
X.com
|
||||||
|
|
|
@ -50,9 +50,24 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||||
|
|
||||||
psl_is_public_suffix(NULL, NULL);
|
psl_is_public_suffix(NULL, NULL);
|
||||||
psl_is_public_suffix(psl, ".ü.com");
|
psl_is_public_suffix(psl, ".ü.com");
|
||||||
|
psl_suffix_wildcard_count(psl);
|
||||||
|
psl_suffix_exception_count(psl);
|
||||||
|
psl_suffix_count(psl);
|
||||||
|
|
||||||
|
psl_free(psl);
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
// non-DAFSA load
|
||||||
|
fp = fmemopen(in + 16, size, "r");
|
||||||
|
assert(fp != NULL);
|
||||||
|
|
||||||
|
psl = psl_load_fp(fp);
|
||||||
|
psl_free(psl);
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
psl = psl_latest(NULL);
|
||||||
psl_free(psl);
|
psl_free(psl);
|
||||||
|
|
||||||
fclose(fp);
|
|
||||||
free(in);
|
free(in);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -29,7 +29,8 @@ if test -z "$1"; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fuzzer=$1
|
fuzzer=$1
|
||||||
workers=4
|
workers=$(($(nproc) - 1))
|
||||||
|
jobs=$workers
|
||||||
|
|
||||||
clang-5.0 \
|
clang-5.0 \
|
||||||
$CFLAGS -I../include -I.. \
|
$CFLAGS -I../include -I.. \
|
||||||
|
@ -41,9 +42,9 @@ clang-5.0 \
|
||||||
mkdir -p ${fuzzer}.new
|
mkdir -p ${fuzzer}.new
|
||||||
|
|
||||||
if test -f ${fuzzer}.dict; then
|
if test -f ${fuzzer}.dict; then
|
||||||
./${fuzzer} -workers=$workers -dict=${fuzzer}.dict ${fuzzer}.new ${fuzzer}.in
|
./${fuzzer} -dict=${fuzzer}.dict ${fuzzer}.new ${fuzzer}.in -jobs=$jobs -workers=$workers
|
||||||
else
|
else
|
||||||
./${fuzzer} -workers=$workers ${fuzzer}.new ${fuzzer}.in
|
./${fuzzer} ${fuzzer}.new ${fuzzer}.in -jobs=$jobs -workers=$workers
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in New Issue