fuzz: make it build again.

How did this pass CI?  I saw this break in my PR, but it's (long)
broken in master.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2021-10-13 14:12:42 +10:30
committed by Christian Decker
parent 67b790e3dc
commit 012dedc3d8
3 changed files with 22 additions and 4 deletions

View File

@@ -10,18 +10,22 @@ FUZZ_TARGETS_BIN := $(FUZZ_TARGETS_SRC:.c=)
FUZZ_COMMON_OBJS := \ FUZZ_COMMON_OBJS := \
common/amount.o \ common/amount.o \
common/addr.o \ common/addr.o \
common/autodata.o \
common/base32.o \ common/base32.o \
common/base64.o \ common/base64.o \
common/bech32.o \ common/bech32.o \
common/bip32.o \ common/bip32.o \
common/bigsize.o \ common/bigsize.o \
common/blockheight_states.o \
common/channel_config.o \ common/channel_config.o \
common/close_tx.o \ common/close_tx.o \
common/channel_id.o \ common/channel_id.o \
common/channel_type.o \
common/daemon.o \ common/daemon.o \
common/daemon_conn.o \ common/daemon_conn.o \
common/derive_basepoints.o \ common/derive_basepoints.o \
common/descriptor_checksum.o \ common/descriptor_checksum.o \
common/features.o \
common/fee_states.o \ common/fee_states.o \
common/hsm_encryption.o \ common/hsm_encryption.o \
common/htlc_state.o \ common/htlc_state.o \
@@ -46,7 +50,8 @@ FUZZ_COMMON_OBJS := \
wire/fromwire.o \ wire/fromwire.o \
wire/onion_wiregen.o \ wire/onion_wiregen.o \
wire/peer_wire.o \ wire/peer_wire.o \
wire/peer_wiregen.o \ wire/peer$(EXP)_wiregen.o \
wire/channel_type_wiregen.o \
wire/tlvstream.o \ wire/tlvstream.o \
wire/towire.o \ wire/towire.o \
wire/wire_io.o \ wire/wire_io.o \

View File

@@ -1,3 +1,5 @@
#include "config.h"
#include <assert.h>
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include <tests/fuzz/libfuzz.h> #include <tests/fuzz/libfuzz.h>

View File

@@ -11,6 +11,8 @@
#include <bitcoin/tx.h> #include <bitcoin/tx.h>
#include <ccan/tal/tal.h> #include <ccan/tal/tal.h>
#include <common/amount.h> #include <common/amount.h>
#include <common/blockheight_states.h>
#include <common/channel_type.h>
#include <common/fee_states.h> #include <common/fee_states.h>
#include <common/initial_channel.h> #include <common/initial_channel.h>
#include <common/setup.h> #include <common/setup.h>
@@ -38,7 +40,8 @@ void run(const uint8_t *data, size_t size)
struct channel_config local, remote; struct channel_config local, remote;
struct basepoints local_basepoints, remote_basepoints; struct basepoints local_basepoints, remote_basepoints;
struct pubkey local_funding_pubkey, remote_funding_pubkey; struct pubkey local_funding_pubkey, remote_funding_pubkey;
bool option_static_remotekey, option_anchor_outputs; bool option_static_remotekey, option_anchor_outputs, wumbo;
struct channel_type *channel_type;
struct channel *channel; struct channel *channel;
fromwire_channel_id(&data, &size, &cid); fromwire_channel_id(&data, &size, &cid);
@@ -59,9 +62,17 @@ void run(const uint8_t *data, size_t size)
fromwire_basepoints(&data, &size, &remote_basepoints); fromwire_basepoints(&data, &size, &remote_basepoints);
fromwire_pubkey(&data, &size, &local_funding_pubkey); fromwire_pubkey(&data, &size, &local_funding_pubkey);
fromwire_pubkey(&data, &size, &remote_funding_pubkey); fromwire_pubkey(&data, &size, &remote_funding_pubkey);
wumbo = fromwire_bool(&data, &size);
option_anchor_outputs = fromwire_bool(&data, &size); option_anchor_outputs = fromwire_bool(&data, &size);
option_static_remotekey = option_anchor_outputs || fromwire_bool(&data, &size); option_static_remotekey = option_anchor_outputs || fromwire_bool(&data, &size);
if (option_anchor_outputs)
channel_type = channel_type_anchor_outputs(tmpctx);
else if (option_static_remotekey)
channel_type = channel_type_static_remotekey(tmpctx);
else
channel_type = channel_type_none(tmpctx);
/* TODO: determine if it makes sense to check at each step for libfuzzer /* TODO: determine if it makes sense to check at each step for libfuzzer
* to deduce pertinent inputs */ * to deduce pertinent inputs */
if (!data || !size) if (!data || !size)
@@ -81,8 +92,8 @@ void run(const uint8_t *data, size_t size)
&remote_basepoints, &remote_basepoints,
&local_funding_pubkey, &local_funding_pubkey,
&remote_funding_pubkey, &remote_funding_pubkey,
option_static_remotekey, channel_type,
option_anchor_outputs, opener); wumbo, opener);
/* TODO: make initial_channel_tx() work with ASAN.. */ /* TODO: make initial_channel_tx() work with ASAN.. */
} }