summaryrefslogtreecommitdiff
path: root/fuzz
diff options
context:
space:
mode:
authorJakub Jelen <jjelen@redhat.com>2020-04-20 16:12:54 +0200
committerFrediano Ziglio <freddy77@gmail.com>2020-04-26 21:35:04 +0100
commit0424cfbe6562c49154e2feef4ad51ca8807c8a42 (patch)
tree6003af88db7a1039c01c267371465f8dedf3f565 /fuzz
parent806335366f5c332efb9d457078199c0e932a72dc (diff)
Fuzz also simpletlv parser
The parser is not covered as it is used for parsing output of real cards (which are not available in tests and emulation). Signed-off-by: Jakub Jelen <jjelen@redhat.com> Acked-by: Frediano Ziglio <fziglio@redhat.com>
Diffstat (limited to 'fuzz')
-rw-r--r--fuzz/fuzz_simpletlv.c27
-rw-r--r--fuzz/meson.build2
2 files changed, 29 insertions, 0 deletions
diff --git a/fuzz/fuzz_simpletlv.c b/fuzz/fuzz_simpletlv.c
new file mode 100644
index 0000000..10a8f08
--- /dev/null
+++ b/fuzz/fuzz_simpletlv.c
@@ -0,0 +1,27 @@
+/* Copyright (c) 2020, Red Hat, Inc.
+ *
+ * Authors: Jakub Jelen <jjelen@redhat.com>
+ *
+ * This code is licensed under the GNU LGPL, version 2.1 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include <stdlib.h>
+#include <libcacard.h>
+#include <simpletlv.h>
+
+#include "fuzzer.h"
+
+int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
+{
+ uint8_t *data = (uint8_t *) Data;
+ size_t outlen = 0;
+ struct simpletlv_member *tlv = NULL;
+
+ tlv = simpletlv_parse(data, Size, &outlen);
+ simpletlv_free(tlv, outlen);
+
+ return 0;
+}
+
+/* vim: set ts=4 sw=4 tw=0 noet expandtab: */
diff --git a/fuzz/meson.build b/fuzz/meson.build
index 73ac64c..31e8040 100644
--- a/fuzz/meson.build
+++ b/fuzz/meson.build
@@ -1,5 +1,6 @@
fuzz_targets = [
'fuzz_xfer',
+ 'fuzz_simpletlv',
]
deps = [libcacard_dep]
@@ -16,6 +17,7 @@ endif
foreach target_name : fuzz_targets
executable(target_name, [extra_sources, target_name + '.c'],
+ objects: libcacard.extract_all_objects(),
c_args : extra_c_args,
dependencies : deps,
)