Skip to content

fuzz-tests: Improved fuzz coverage for fuzz-addr #8232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
8 changes: 5 additions & 3 deletions tests/fuzz/fuzz-addr.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ void init(int *argc, char ***argv)

void run(const uint8_t *data, size_t size)
{
uint8_t *script_pubkey = tal_dup_arr(tmpctx, uint8_t, data, size, 0);
if(size == 22 || size == 23 || size == 25 || size == 34) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm skeptical that this materially improves the fuzzer's ability to find new coverage, since all the size checks are also present deeper in the encode_scriptpubkey_to_addr logic. I think the increased coverage you saw is likely due to the fact that this change introduces at least 5 new branches for the fuzzer to find.

This change also doesn't seem very future-proof -- if support for a new script type is added, the fuzzer won't be able to exercise that code.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! Thanks a lot for the feedback — really appreciate it.

I've removed the changes to fuzz-addr.c as suggested, and kept only the corpus update. Also, I ran the corpus minimization steps using ./run.py corpora --merge_dir, and added the minimized corpus.

I'm still getting the hang of fuzzing, so happy to learn and iterate!

uint8_t *script_pubkey = tal_dup_arr(tmpctx, uint8_t, data, size, 0);

encode_scriptpubkey_to_addr(tmpctx, chainparams, script_pubkey);
encode_scriptpubkey_to_addr(tmpctx, chainparams, script_pubkey);

clean_tmpctx();
clean_tmpctx();
}
}