aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test-x509.c
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2019-02-24 16:52:54 (GMT)
committerJouni Malinen <j@w1.fi>2019-02-25 17:48:49 (GMT)
commitf3e671591e6938e27aa15ba52f258617456a8fac (patch)
tree9594e98b5ca7676a7bac26cc61f3f0dbef64980f /tests/test-x509.c
parentbb05d03606add80708480b621a73fa9cc3ebbe6d (diff)
downloadhostap-f3e671591e6938e27aa15ba52f258617456a8fac.zip
hostap-f3e671591e6938e27aa15ba52f258617456a8fac.tar.gz
hostap-f3e671591e6938e27aa15ba52f258617456a8fac.tar.bz2
tests: libFuzzer integration for test-json and test-x509
Allow these test tools to be used with libFuzzer in addition to afl-fuzz. Signed-off-by: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'tests/test-x509.c')
-rw-r--r--tests/test-x509.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/tests/test-x509.c b/tests/test-x509.c
index 194f229..055446e 100644
--- a/tests/test-x509.c
+++ b/tests/test-x509.c
@@ -1,6 +1,6 @@
/*
* Testing tool for X.509v3 routines
- * Copyright (c) 2006-2009, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2006-2019, Jouni Malinen <j@w1.fi>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
@@ -12,6 +12,16 @@
#include "tls/x509v3.h"
+#ifdef TEST_LIBFUZZER
+int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
+{
+ struct x509_certificate *cert;
+
+ cert = x509_certificate_parse(data, size);
+ x509_certificate_free(cert);
+ return 0;
+}
+#else /* TEST_LIBFUZZER */
int main(int argc, char *argv[])
{
FILE *f;
@@ -34,3 +44,4 @@ int main(int argc, char *argv[])
return 0;
}
+#endif /* TEST_LIBFUZZER */