mirror of https://gerrit.osmocom.org/asn1c
added fuzzer for XER test 70
This commit is contained in:
parent
4fe2882262
commit
c8c286ab11
|
@ -51,10 +51,24 @@ fi
|
|||
OFS=$IFS
|
||||
IFS="."
|
||||
set $args
|
||||
data_dir=$(echo "$1" | sed -e s/check-/data-/)
|
||||
shift
|
||||
IFS=$OFS
|
||||
AFLAGS="$*"
|
||||
|
||||
if [ -d ${data_dir} ]; then
|
||||
OPT_DATA_DIR="../${data_dir}"
|
||||
else
|
||||
OPT_DATA_DIR=""
|
||||
fi
|
||||
|
||||
if test "${LIBFUZZER_CFLAGS}" && grep LLVMFuzzer ${source_full} > /dev/null;
|
||||
then
|
||||
MAKE_FUZZER=yes
|
||||
else
|
||||
MAKE_FUZZER=no
|
||||
fi
|
||||
|
||||
# Assume the test fails. Will be removed when it passes well.
|
||||
testdir=test-${args}
|
||||
if [ -f "${testdir}-FAILED" ]; then
|
||||
|
@ -65,13 +79,6 @@ touch "${testdir}-FAILED"
|
|||
mkdir -p "${testdir}"
|
||||
ln -fns "../${source_full}" "${testdir}"
|
||||
|
||||
if test "${LIBFUZZER_CFLAGS}" && grep LLVMFuzzer ${source_full} > /dev/null;
|
||||
then
|
||||
MAKE_FUZZER=yes
|
||||
else
|
||||
MAKE_FUZZER=no
|
||||
fi
|
||||
|
||||
asn_module=$(echo "${abs_top_srcdir}/tests/tests-asn1c-compiler/${testno}"-*.asn1)
|
||||
|
||||
AUTOGENERATED="# This file is autogenerated by $0 ${source_full} ${AFLAGS}"
|
||||
|
@ -116,7 +123,7 @@ cat <<TARGETS >> "${testdir}/Makefile.targets"
|
|||
check-fuzzer:
|
||||
TARGETS
|
||||
else
|
||||
CHECK_FUZZER="UBSAN_OPTIONS=print_stacktrace=1 ./check-fuzzer -timeout=3 -max_total_time=60 -max_len=512 -detect_leaks=1"
|
||||
CHECK_FUZZER="UBSAN_OPTIONS=print_stacktrace=1 ./check-fuzzer -timeout=3 -max_total_time=60 -max_len=512 -detect_leaks=1 ${OPT_DATA_DIR}"
|
||||
cat <<TARGETS >> "${testdir}/Makefile.targets"
|
||||
check-fuzzer: \$(OBJS)
|
||||
rm -f ${source_obj}
|
||||
|
|
|
@ -277,6 +277,19 @@ process(const char *fname) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_LIBFUZZER
|
||||
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
||||
PDU_t *st = 0;
|
||||
asn_dec_rval_t rval;
|
||||
rval = asn_decode(0, ATS_BASIC_XER, &asn_DEF_PDU, (void **)&st, Data, Size);
|
||||
assert(rval.consumed <= Size);
|
||||
ASN_STRUCT_FREE(asn_DEF_PDU, st);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int
|
||||
main() {
|
||||
DIR *dir;
|
||||
|
@ -309,3 +322,4 @@ main() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -256,6 +256,19 @@ process(const char *fname) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_LIBFUZZER
|
||||
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
||||
PDU_t *st = 0;
|
||||
asn_dec_rval_t rval;
|
||||
rval = asn_decode(0, ATS_BASIC_XER, &asn_DEF_PDU, (void **)&st, Data, Size);
|
||||
assert(rval.consumed <= Size);
|
||||
ASN_STRUCT_FREE(asn_DEF_PDU, st);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int
|
||||
main() {
|
||||
DIR *dir;
|
||||
|
@ -286,3 +299,4 @@ main() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue