From 4f2ae48c5401f289c7defca7a16df67c13b9c679 Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Fri, 30 Oct 2020 15:29:07 +0100 Subject: [PATCH] fuzz: add a fuzz target for common/descriptor_checksum A small one just to check that we don't crash nor go out of bounds! Signed-off-by: Antoine Poinsot --- tests/fuzz/Makefile | 1 + tests/fuzz/fuzz-descriptor_checksum.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 tests/fuzz/fuzz-descriptor_checksum.c diff --git a/tests/fuzz/Makefile b/tests/fuzz/Makefile index d876602cf..f37f3f1b6 100644 --- a/tests/fuzz/Makefile +++ b/tests/fuzz/Makefile @@ -21,6 +21,7 @@ FUZZ_COMMON_OBJS := \ common/daemon.o \ common/daemon_conn.o \ common/derive_basepoints.o \ + common/descriptor_checksum.o \ common/fee_states.o \ common/htlc_state.o \ common/permute_tx.o \ diff --git a/tests/fuzz/fuzz-descriptor_checksum.c b/tests/fuzz/fuzz-descriptor_checksum.c new file mode 100644 index 000000000..c37412bd6 --- /dev/null +++ b/tests/fuzz/fuzz-descriptor_checksum.c @@ -0,0 +1,20 @@ +#include + +#include +#include + +void init(int *argc, char ***argv) +{ +} + +void run(const uint8_t *data, size_t size) +{ + char *string; + struct descriptor_checksum checksum; + + /* We should not crash nor overflow the checksum buffer. */ + + string = to_string(NULL, data, size); + descriptor_checksum(string, tal_count(string), &checksum); + tal_free(string); +}