Skip to content

Commit 074cb64

Browse files
tests: Add ParseHDKeypath(...) (bip32) fuzzing harness
1 parent 0dc5907 commit 074cb64

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/Makefile.test.include

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ FUZZ_TARGETS = \
3333
test/fuzz/messageheader_deserialize \
3434
test/fuzz/netaddr_deserialize \
3535
test/fuzz/out_point_deserialize \
36+
test/fuzz/parse_hd_keypath \
3637
test/fuzz/parse_iso8601 \
3738
test/fuzz/partial_merkle_tree_deserialize \
3839
test/fuzz/partially_signed_transaction_deserialize \
@@ -518,6 +519,12 @@ test_fuzz_tx_out_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
518519
test_fuzz_tx_out_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
519520
test_fuzz_tx_out_LDADD = $(FUZZ_SUITE_LD_COMMON)
520521

522+
test_fuzz_parse_hd_keypath_SOURCES = $(FUZZ_SUITE) test/fuzz/parse_hd_keypath.cpp
523+
test_fuzz_parse_hd_keypath_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
524+
test_fuzz_parse_hd_keypath_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
525+
test_fuzz_parse_hd_keypath_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
526+
test_fuzz_parse_hd_keypath_LDADD = $(FUZZ_SUITE_LD_COMMON)
527+
521528
endif # ENABLE_FUZZ
522529

523530
nodist_test_test_bitcoin_SOURCES = $(GENERATED_TEST_FILES)

src/test/fuzz/parse_hd_keypath.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright (c) 2009-2019 The Bitcoin Core developers
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
#include <test/fuzz/fuzz.h>
6+
#include <util/bip32.h>
7+
8+
void test_one_input(const std::vector<uint8_t>& buffer)
9+
{
10+
const std::string keypath_str(buffer.begin(), buffer.end());
11+
std::vector<uint32_t> keypath;
12+
(void)ParseHDKeypath(keypath_str, keypath);
13+
}

0 commit comments

Comments
 (0)