Skip to content

Commit

Permalink
fuzz: fix fuzzing compilation.
Browse files Browse the repository at this point in the history
It had bitrotted.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell authored and niftynei committed Jul 25, 2022
1 parent 7bbfef5 commit 8f6afed
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ $(ALL_PROGRAMS) $(ALL_TEST_PROGRAMS):
# which brings its own main().
FUZZ_LDFLAGS = -fsanitize=fuzzer
$(ALL_FUZZ_TARGETS):
@$(call VERBOSE, "ld $@", $(LINK.o) $(filter-out %.a,$^) $(LOADLIBES) $(EXTERNAL_LDLIBS) $(LDLIBS) $(FUZZ_LDFLAGS) -o $@)
@$(call VERBOSE, "ld $@", $(LINK.o) $(filter-out %.a,$^) $(LOADLIBES) $(EXTERNAL_LDLIBS) $(LDLIBS) libccan.a $(FUZZ_LDFLAGS) -o $@)


# Everything depends on the CCAN headers, and Makefile
Expand Down
4 changes: 3 additions & 1 deletion tests/fuzz/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ FUZZ_COMMON_OBJS := \
common/blockheight_states.o \
common/channel_config.o \
common/close_tx.o \
common/configdir.o \
common/channel_id.o \
common/channel_type.o \
common/daemon.o \
Expand All @@ -32,13 +33,14 @@ FUZZ_COMMON_OBJS := \
common/permute_tx.o \
common/initial_channel.o \
common/initial_commit_tx.o \
common/json.o \
common/json_parse_simple.o \
common/json_stream.o \
common/key_derive.o \
common/keyset.o \
common/msg_queue.o \
common/memleak.o \
common/node_id.o \
common/psbt_keypath.o \
common/wireaddr.o \
common/setup.o \
common/status.o \
Expand Down
2 changes: 1 addition & 1 deletion tests/fuzz/fuzz-close_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void run(const uint8_t *data, size_t size)
PUBKEY_CMPR_LEN, pk2);
funding_script = bitcoin_redeem_2of2(tmpctx, pk1, pk2);

create_close_tx(tmpctx, chainparams, our_script,
create_close_tx(tmpctx, chainparams, NULL, NULL, our_script,
their_script, funding_script, &outpoint,
funding, to_us, to_them, dust_limit);

Expand Down
3 changes: 2 additions & 1 deletion tests/fuzz/fuzz-hsm_encryption.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ void run(const uint8_t *data, size_t size)
struct secret *hsm_secret, decrypted_hsm_secret, encryption_key;
char *passphrase;
struct encrypted_hsm_secret encrypted_secret;
char *emsg;

/* Take the first 32 bytes as the plaintext hsm_secret seed,
* and the remaining ones as the passphrase. */
hsm_secret = (struct secret *)tal_dup_arr(NULL, u8, data, 32, 0);
passphrase = to_string(NULL, data + 32, size - 32);

/* A valid seed, a valid passphrase. This should not fail. */
assert(!hsm_secret_encryption_key(passphrase, &encryption_key));
assert(!hsm_secret_encryption_key_with_exitcode(passphrase, &encryption_key, &emsg));
/* Roundtrip */
assert(encrypt_hsm_secret(&encryption_key, hsm_secret,
&encrypted_secret));
Expand Down
1 change: 1 addition & 0 deletions tests/fuzz/fuzz-initial_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ void run(const uint8_t *data, size_t size)
wumbo, opener);

/* TODO: make initial_channel_tx() work with ASAN.. */
(void)channel;
}

clean_tmpctx();
Expand Down

0 comments on commit 8f6afed

Please sign in to comment.