-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
93 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
#include <string> | ||
|
||
extern bool rust_miniscript_from_str(const char* miniscript_str); | ||
extern bool rust_bitcoin_script(const char* miniscript_str); | ||
extern char* rust_bitcoin_psbt(const char* miniscript_str); | ||
extern bool rust_bitcoin_script(const uint8_t *data, size_t len); | ||
extern char* rust_bitcoin_psbt(const uint8_t *data, size_t len); | ||
extern char* rust_miniscript_from_str_check_key(const char* miniscript_str); | ||
extern char* rust_bitcoin_des_block(const uint8_t *data, size_t len); | ||
extern char* rust_bitcoin_prefilledtransaction(const uint8_t *data, size_t len); | ||
extern bool rust_bitcoin_addrv2(uint8_t *data, size_t len, uint64_t *count); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include <fuzzer/FuzzedDataProvider.h> | ||
#include <string> | ||
#include <iostream> | ||
#include <optional> | ||
#include <stdio.h> | ||
|
||
#include "addrv2.h" | ||
#include "bitcoin/src/protocol.h" | ||
#include "bitcoin/src/streams.h" | ||
|
||
extern "C" bool rust_bitcoin_addrv2(uint8_t *data, size_t len, uint64_t *count); | ||
extern "C" bool go_btcd_addrv2(uint8_t *data, size_t len, uint64_t *count); | ||
|
||
std::optional<uint64_t> Core(Span<const uint8_t> buffer) | ||
{ | ||
std::vector<CAddress> addrs; | ||
DataStream ds{buffer}; | ||
try { | ||
ds >> CAddress::V2_NETWORK(addrs); | ||
if (addrs.size() > 1000) return std::nullopt; | ||
} catch (const std::ios_base::failure&) { | ||
return std::nullopt; | ||
} | ||
|
||
return addrs.size(); | ||
} | ||
|
||
void Addrv2(FuzzedDataProvider& provider) | ||
{ | ||
std::vector<uint8_t> buffer{provider.ConsumeRemainingBytes<uint8_t>()}; | ||
uint64_t count_rust = 0, count_btcd = 0; | ||
bool rust_bitcoin{rust_bitcoin_addrv2(buffer.data(), buffer.size(), &count_rust)}; | ||
bool btcd{go_btcd_addrv2(buffer.data(), buffer.size(), &count_btcd)}; | ||
std::optional<uint64_t> core{Core(buffer)}; | ||
assert(core.has_value() == rust_bitcoin); | ||
assert(core.has_value() == btcd); | ||
|
||
if (core.has_value()) { | ||
assert(*core == count_rust); | ||
assert(*core >= count_btcd); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#ifndef NET_ADDRESS_H | ||
#define NET_ADDRESS_H | ||
|
||
#include <fuzzer/FuzzedDataProvider.h> | ||
|
||
void Addrv2(FuzzedDataProvider& provider); | ||
#endif |