fuzz: test bolt12 bech32 decoding

This commit is contained in:
Matt Morehouse 2023-10-26 14:38:09 -05:00 committed by Rusty Russell
parent b19b08d749
commit b73f921a91
2 changed files with 23 additions and 0 deletions

View File

@ -23,6 +23,7 @@ FUZZ_COMMON_OBJS := \
common/bigsize.o \
common/blockheight_states.o \
common/bolt11.o \
common/bolt12_merkle.o \
common/channel_config.o \
common/close_tx.o \
common/configdir.o \
@ -56,6 +57,7 @@ FUZZ_COMMON_OBJS := \
common/type_to_string.o \
common/utils.o \
common/version.o \
wire/bolt12_wiregen.o \
wire/fromwire.o \
wire/onion_wiregen.o \
wire/peer_wire.o \

View File

@ -0,0 +1,21 @@
/* A fuzz target for the bolt12-specific bech32 decoding logic. */
#include "config.h"
#include <common/setup.h>
#include <common/utils.h>
#include <stddef.h>
#include <tests/fuzz/libfuzz.h>
/* Include bolt12.c directly, to gain access to string_to_data(). */
#include "../../common/bolt12.c"
void init(int *argc, char ***argv) { common_setup("fuzzer"); }
void run(const u8 *data, size_t size)
{
size_t dlen;
char *fail;
string_to_data(tmpctx, (const char *)data, size, "lno", &dlen, &fail);
clean_tmpctx();
}