From 162b81fbb105963586cfbd6b70baac7367aa84af Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 25 Jun 2024 16:33:47 +0000 Subject: [PATCH] Use `test_msg_exact` in `channl_update` fuzz testing Gossip messages should always use `test_msg_exact` to ensure they round-trip during signature validation. --- fuzz/src/msg_targets/gen_target.sh | 5 ++++- fuzz/src/msg_targets/mod.rs | 2 +- fuzz/src/msg_targets/msg_channel_update.rs | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/fuzz/src/msg_targets/gen_target.sh b/fuzz/src/msg_targets/gen_target.sh index 05997c075..71c3d895b 100755 --- a/fuzz/src/msg_targets/gen_target.sh +++ b/fuzz/src/msg_targets/gen_target.sh @@ -39,14 +39,17 @@ GEN_TEST lightning::ln::msgs::ChannelReestablish test_msg_simple "" GEN_TEST lightning::ln::msgs::DecodedOnionErrorPacket test_msg "" +# Gossip messages need to use `test_msg_exact` to ensure that messages +# round-trip exactly when doing signature validation. GEN_TEST lightning::ln::msgs::ChannelAnnouncement test_msg_exact "" GEN_TEST lightning::ln::msgs::NodeAnnouncement test_msg_exact "" +GEN_TEST lightning::ln::msgs::ChannelUpdate test_msg_exact "" + GEN_TEST lightning::ln::msgs::QueryShortChannelIds test_msg "" GEN_TEST lightning::ln::msgs::ReplyChannelRange test_msg "" GEN_TEST lightning::ln::msgs::ErrorMessage test_msg_hole ", 32, 2" GEN_TEST lightning::ln::msgs::WarningMessage test_msg_hole ", 32, 2" -GEN_TEST lightning::ln::msgs::ChannelUpdate test_msg_hole ", 108, 1" GEN_TEST lightning::ln::channel_state::ChannelDetails test_msg_simple "" diff --git a/fuzz/src/msg_targets/mod.rs b/fuzz/src/msg_targets/mod.rs index 15750a9a5..16721fa62 100644 --- a/fuzz/src/msg_targets/mod.rs +++ b/fuzz/src/msg_targets/mod.rs @@ -25,11 +25,11 @@ pub mod msg_channel_reestablish; pub mod msg_decoded_onion_error_packet; pub mod msg_channel_announcement; pub mod msg_node_announcement; +pub mod msg_channel_update; pub mod msg_query_short_channel_ids; pub mod msg_reply_channel_range; pub mod msg_error_message; pub mod msg_warning_message; -pub mod msg_channel_update; pub mod msg_channel_details; pub mod msg_open_channel_v2; pub mod msg_accept_channel_v2; diff --git a/fuzz/src/msg_targets/msg_channel_update.rs b/fuzz/src/msg_targets/msg_channel_update.rs index 358305b9d..4dc8c1403 100644 --- a/fuzz/src/msg_targets/msg_channel_update.rs +++ b/fuzz/src/msg_targets/msg_channel_update.rs @@ -17,11 +17,11 @@ use crate::utils::test_logger; #[inline] pub fn msg_channel_update_test(data: &[u8], _out: Out) { - test_msg_hole!(lightning::ln::msgs::ChannelUpdate, data, 108, 1); + test_msg_exact!(lightning::ln::msgs::ChannelUpdate, data); } #[no_mangle] pub extern "C" fn msg_channel_update_run(data: *const u8, datalen: usize) { let data = unsafe { std::slice::from_raw_parts(data, datalen) }; - test_msg_hole!(lightning::ln::msgs::ChannelUpdate, data, 108, 1); + test_msg_exact!(lightning::ln::msgs::ChannelUpdate, data); } -- 2.39.5