More fuzzer improvements
This commit is contained in:
parent
43f460d4c5
commit
f304dbe324
|
@ -31,12 +31,16 @@ fuzz-coverage: $(PSL_TESTS)
|
||||||
|
|
||||||
oss-fuzz:
|
oss-fuzz:
|
||||||
if test "$$OUT" != ""; then \
|
if test "$$OUT" != ""; then \
|
||||||
|
if $$(ldd ../src/.libs/libpsl.so|grep -q libidn2); then XLIBS="-lidn2 -lunistring"; \
|
||||||
|
elif $$(ldd ../src/.libs/libpsl.so|grep -q libidn); then XLIBS="-lidn -lunistring"; \
|
||||||
|
elif $$(ldd ../src/.libs/libpsl.so|grep -q libicu); then XLIBS="-licuuc -licudata"; \
|
||||||
|
else XLIBS=""; fi; \
|
||||||
for ccfile in *_fuzzer.c; do \
|
for ccfile in *_fuzzer.c; do \
|
||||||
fuzzer=$$(basename $$ccfile .c); \
|
fuzzer=$$(basename $$ccfile .c); \
|
||||||
$$CXX $$CXXFLAGS -I$(top_srcdir)/include -I$(top_srcdir) \
|
$$CXX $$CXXFLAGS -I$(top_srcdir)/include -I$(top_srcdir) \
|
||||||
"$${fuzzer}.c" -o "$${fuzzer}" \
|
"$${fuzzer}.c" -o "$${fuzzer}" \
|
||||||
../src/.libs/libpsl.a $${LIB_FUZZING_ENGINE} -Wl,-Bstatic \
|
../src/.libs/libpsl.a $${LIB_FUZZING_ENGINE} -Wl,-Bstatic \
|
||||||
-lidn2 -lunistring \
|
$$XLIBS \
|
||||||
-Wl,-Bdynamic; \
|
-Wl,-Bdynamic; \
|
||||||
done; \
|
done; \
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -29,11 +29,16 @@
|
||||||
#include <stdlib.h> // malloc, free
|
#include <stdlib.h> // malloc, free
|
||||||
#include <string.h> // memcpy
|
#include <string.h> // memcpy
|
||||||
|
|
||||||
|
#if defined(WITH_LIBICU)
|
||||||
|
#include <unicode/uclean.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "libpsl.h"
|
#include "libpsl.h"
|
||||||
#include "fuzzer.h"
|
#include "fuzzer.h"
|
||||||
|
|
||||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||||
{
|
{
|
||||||
|
static int first_run = 1;
|
||||||
char *domain = (char *) malloc(size + 1), *res;
|
char *domain = (char *) malloc(size + 1), *res;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
@ -46,7 +51,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||||
psl_ctx_t *psl;
|
psl_ctx_t *psl;
|
||||||
psl = (psl_ctx_t *) psl_builtin();
|
psl = (psl_ctx_t *) psl_builtin();
|
||||||
|
|
||||||
psl_is_public_suffix(NULL, domain);
|
|
||||||
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);
|
||||||
|
@ -65,15 +69,23 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||||
|
|
||||||
psl_free(psl);
|
psl_free(psl);
|
||||||
|
|
||||||
psl_check_version_number(1);
|
if (first_run) {
|
||||||
psl_get_version();
|
psl_is_public_suffix(NULL, domain);
|
||||||
psl_dist_filename();
|
psl_check_version_number(1);
|
||||||
psl_builtin_outdated();
|
psl_get_version();
|
||||||
psl_builtin_filename();
|
psl_dist_filename();
|
||||||
psl_builtin_sha1sum();
|
psl_builtin_outdated();
|
||||||
psl_builtin_file_time();
|
psl_builtin_filename();
|
||||||
|
psl_builtin_sha1sum();
|
||||||
|
psl_builtin_file_time();
|
||||||
|
first_run = 0;
|
||||||
|
}
|
||||||
|
|
||||||
free(domain);
|
free(domain);
|
||||||
|
|
||||||
|
#if defined(WITH_LIBICU)
|
||||||
|
u_cleanup(); // free all library internal memory to avoid memory leaks being reported
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,11 +32,16 @@ fuzzer=$1
|
||||||
workers=$(($(nproc) - 1))
|
workers=$(($(nproc) - 1))
|
||||||
jobs=$workers
|
jobs=$workers
|
||||||
|
|
||||||
|
if $(ldd ../src/.libs/libpsl.so|grep -q libidn2); then XLIBS="-lidn2 -lunistring"; \
|
||||||
|
elif $(ldd ../src/.libs/libpsl.so|grep -q libidn); then XLIBS="-lidn -lunistring"; \
|
||||||
|
elif $(ldd ../src/.libs/libpsl.so|grep -q libicu); then XLIBS="-licuuc -licudata"; \
|
||||||
|
else XLIBS=""; fi; \
|
||||||
|
|
||||||
clang-5.0 \
|
clang-5.0 \
|
||||||
$CFLAGS -I../include -I.. \
|
$CFLAGS -Og -g -I../include -I.. \
|
||||||
${fuzzer}.c -o ${fuzzer} \
|
${fuzzer}.c -o ${fuzzer} \
|
||||||
-Wl,-Bstatic ../src/.libs/libpsl.a -lFuzzer \
|
-Wl,-Bstatic ../src/.libs/libpsl.a -lFuzzer \
|
||||||
-Wl,-Bdynamic -lidn2 -lunistring -lclang-5.0 -lstdc++
|
-Wl,-Bdynamic $XLIBS -lclang-5.0 -lstdc++
|
||||||
|
|
||||||
# create directory for NEW test corpora (covering new areas of code)
|
# create directory for NEW test corpora (covering new areas of code)
|
||||||
mkdir -p ${fuzzer}.new
|
mkdir -p ${fuzzer}.new
|
||||||
|
|
Loading…
Reference in New Issue