fuzz: Migrate p2p fuzz targets to new encoding
What changed, and why it matters
This commit only updates internal fuzz testing code to use a newer encoding/decoding helper crate. It does not change any production code that real users or network peers would run, and it does not fix or introduce any security vulnerability.
No action required; this is a test-only refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch migrates three fuzz targets from bitcoin::consensus::encode::{deserialize, serialize} to bitcoin_consensus_encoding::{decode_from_slice, encode_to_vec}. These are test-only files under fuzz/fuzz_targets/. No runtime library or application code is modified, and no parsing logic or behavior changes.
Changed components
fuzz/fuzz_targets/bitcoin/deserialize_prefilled_transaction.rsfuzz/fuzz_targets/p2p/deserialize_addrv2.rsfuzz/fuzz_targets/p2p/deserialize_raw_net_msg.rsInspect captured patch +4 / −4
diff --git a/fuzz/fuzz_targets/bitcoin/deserialize_prefilled_transaction.rs b/fuzz/fuzz_targets/bitcoin/deserialize_prefilled_transaction.rs
index 1fadf12f..5836381d 100644
--- a/fuzz/fuzz_targets/bitcoin/deserialize_prefilled_transaction.rs
+++ b/fuzz/fuzz_targets/bitcoin/deserialize_prefilled_transaction.rs
@@ -9,12 +9,12 @@ fn main() {}
fn do_test(data: &[u8]) {
// We already fuzz Transactions in `./deserialize_transaction.rs`.
let tx_result: Result<p2p::bip152::PrefilledTransaction, _> =
- bitcoin::consensus::encode::deserialize(data);
+ bitcoin_consensus_encoding::decode_from_slice(data);
match tx_result {
Err(_) => {}
Ok(tx) => {
- let ser = bitcoin::consensus::encode::serialize(&tx);
+ let ser = bitcoin_consensus_encoding::encode_to_vec(&tx);
assert_eq!(&ser[..], data);
}
}
diff --git a/fuzz/fuzz_targets/p2p/deserialize_addrv2.rs b/fuzz/fuzz_targets/p2p/deserialize_addrv2.rs
index 5b89442f..7800ebfa 100644
--- a/fuzz/fuzz_targets/p2p/deserialize_addrv2.rs
+++ b/fuzz/fuzz_targets/p2p/deserialize_addrv2.rs
@@ -7,7 +7,7 @@ use libfuzzer_sys::fuzz_target;
fn main() {}
fn do_test(data: &[u8]) {
- let _: Result<p2p::address::AddrV2, _> = bitcoin::consensus::encode::deserialize(data);
+ let _: Result<p2p::address::AddrV2, _> = bitcoin_consensus_encoding::decode_from_slice(data);
}
fuzz_target!(|data| {
diff --git a/fuzz/fuzz_targets/p2p/deserialize_raw_net_msg.rs b/fuzz/fuzz_targets/p2p/deserialize_raw_net_msg.rs
index 7e5ad13a..39ef83fe 100644
--- a/fuzz/fuzz_targets/p2p/deserialize_raw_net_msg.rs
+++ b/fuzz/fuzz_targets/p2p/deserialize_raw_net_msg.rs
@@ -8,7 +8,7 @@ fn main() {}
fn do_test(data: &[u8]) {
let _: Result<p2p::message::V1NetworkMessage, _> =
- bitcoin::consensus::encode::deserialize(data);
+ bitcoin_consensus_encoding::decode_from_slice(data);
}
fuzz_target!(|data| {
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.