Skip to content

Commit 122c0d4

Browse files
committed
Add msg fuzz target for Writeable
1 parent d556bee commit 122c0d4

20 files changed

+924
-2
lines changed

fuzz/Cargo.toml

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,98 @@ path = "fuzz_targets/msg_targets/msg_node_announcement_target.rs"
152152
name = "msg_onion_hop_data_target"
153153
path = "fuzz_targets/msg_targets/msg_onion_hop_data_target.rs"
154154

155+
# message fuzz targets with Writeable
155156
[[bin]]
156157
name = "msg_accept_channel_target_writeable"
157-
path = "fuzz_targets/msg_accept_channel_target_writeable.rs"
158+
path = "fuzz_targets/msg_targets/msg_accept_channel_target_writeable.rs"
159+
160+
[[bin]]
161+
name = "msg_announcement_signatures_target_writeable"
162+
path = "fuzz_targets/msg_targets/msg_announcement_signatures_target_writeable.rs"
163+
164+
[[bin]]
165+
name = "msg_channel_reestablish_target_writeable"
166+
path = "fuzz_targets/msg_targets/msg_channel_reestablish_target_writeable.rs"
167+
168+
[[bin]]
169+
name = "msg_closing_signed_target_writeable"
170+
path = "fuzz_targets/msg_targets/msg_closing_signed_target_writeable.rs"
171+
172+
[[bin]]
173+
name = "msg_commitment_signed_target_writeable"
174+
path = "fuzz_targets/msg_targets/msg_commitment_signed_target_writeable.rs"
175+
176+
[[bin]]
177+
name = "msg_decoded_onion_error_packet_target_writeable"
178+
path = "fuzz_targets/msg_targets/msg_decoded_onion_error_packet_target_writeable.rs"
179+
180+
[[bin]]
181+
name = "msg_funding_created_target_writeable"
182+
path = "fuzz_targets/msg_targets/msg_funding_created_target_writeable.rs"
183+
184+
[[bin]]
185+
name = "msg_funding_locked_target_writeable"
186+
path = "fuzz_targets/msg_targets/msg_funding_locked_target_writeable.rs"
187+
188+
[[bin]]
189+
name = "msg_funding_signed_target_writeable"
190+
path = "fuzz_targets/msg_targets/msg_funding_signed_target_writeable.rs"
191+
192+
[[bin]]
193+
name = "msg_init_target_writeable"
194+
path = "fuzz_targets/msg_targets/msg_init_target_writeable.rs"
195+
196+
[[bin]]
197+
name = "msg_open_channel_target_writeable"
198+
path = "fuzz_targets/msg_targets/msg_open_channel_target_writeable.rs"
199+
200+
[[bin]]
201+
name = "msg_revoke_and_ack_target_writeable"
202+
path = "fuzz_targets/msg_targets/msg_revoke_and_ack_target_writeable.rs"
203+
204+
[[bin]]
205+
name = "msg_shutdown_target_writeable"
206+
path = "fuzz_targets/msg_targets/msg_shutdown_target_writeable.rs"
207+
208+
[[bin]]
209+
name = "msg_update_fail_htlc_target_writeable"
210+
path = "fuzz_targets/msg_targets/msg_update_fail_htlc_target_writeable.rs"
211+
212+
[[bin]]
213+
name = "msg_update_fail_malformed_htlc_target_writeable"
214+
path = "fuzz_targets/msg_targets/msg_update_fail_malformed_htlc_target_writeable.rs"
215+
216+
[[bin]]
217+
name = "msg_update_fee_target_writeable"
218+
path = "fuzz_targets/msg_targets/msg_update_fee_target_writeable.rs"
219+
220+
[[bin]]
221+
name = "msg_update_fulfill_htlc_target_writeable"
222+
path = "fuzz_targets/msg_targets/msg_update_fulfill_htlc_target_writeable.rs"
223+
224+
[[bin]]
225+
name = "msg_channel_announcement_target_writeable"
226+
path = "fuzz_targets/msg_targets/msg_channel_announcement_target_writeable.rs"
227+
228+
[[bin]]
229+
name = "msg_channel_update_target_writeable"
230+
path = "fuzz_targets/msg_targets/msg_channel_update_target_writeable.rs"
231+
232+
[[bin]]
233+
name = "msg_node_announcement_target_writeable"
234+
path = "fuzz_targets/msg_targets/msg_node_announcement_target_writeable.rs"
235+
236+
[[bin]]
237+
name = "msg_update_add_htlc_target_writeable"
238+
path = "fuzz_targets/msg_targets/msg_update_add_htlc_target_writeable.rs"
239+
240+
[[bin]]
241+
name = "msg_error_message_target_writeable"
242+
path = "fuzz_targets/msg_targets/msg_error_message_target_writeable.rs"
243+
244+
[[bin]]
245+
name = "msg_onion_hop_data_target_writeable"
246+
path = "fuzz_targets/msg_targets/msg_onion_hop_data_target_writeable.rs"
158247

159248
[[bin]]
160249
name = "msg_ping_target_writeable"
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/sh
2+
3+
GEN_TEST() {
4+
tn=$(echo $1 | sed 's/\([a-z0-9]\)\([A-Z]\)/\1_\2/g')
5+
fn=msg_$(echo $tn | tr '[:upper:]' '[:lower:]')_target_writeable.rs
6+
cat msg_target_template.txt | sed s/MSG_TARGET/$1/ | sed "s/TEST_MSG/$2/" | sed "s/EXTRA_ARGS/$3/" > $fn
7+
}
8+
9+
GEN_TEST AcceptChannel test_msg_writeable ""
10+
GEN_TEST AnnouncementSignatures test_msg_writeable ""
11+
GEN_TEST ChannelReestablish test_msg_writeable ""
12+
GEN_TEST ClosingSigned test_msg_writeable ""
13+
GEN_TEST CommitmentSigned test_msg_writeable ""
14+
GEN_TEST DecodedOnionErrorPacket test_msg_writeable ""
15+
GEN_TEST FundingCreated test_msg_writeable ""
16+
GEN_TEST FundingLocked test_msg_writeable ""
17+
GEN_TEST FundingSigned test_msg_writeable ""
18+
#GEN_TEST Init test_msg_writeable ""
19+
GEN_TEST OpenChannel test_msg_writeable ""
20+
GEN_TEST RevokeAndACK test_msg_writeable ""
21+
GEN_TEST Shutdown test_msg_writeable ""
22+
GEN_TEST UpdateFailHTLC test_msg_writeable ""
23+
GEN_TEST UpdateFailMalformedHTLC test_msg_writeable ""
24+
GEN_TEST UpdateFee test_msg_writeable ""
25+
GEN_TEST UpdateFulfillHTLC test_msg_writeable ""
26+
27+
#GEN_TEST ChannelAnnouncement test_msg_writeable_exact ""
28+
#GEN_TEST ChannelUpdate test_msg_writeable_exact ""
29+
#GEN_TEST NodeAnnouncement test_msg_writeable_exact ""
30+
31+
GEN_TEST UpdateAddHTLC test_msg_writeable_hole ", 85, 33"
32+
#GEN_TEST ErrorMessage test_msg_writeable_hole ", 32, 2"
33+
#GEN_TEST OnionHopData test_msg_writeable_hole ", 1+8+8+4, 12"
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// This file is auto-generated by gen_target.sh based on msg_target_template.txt
2+
// To modify it, modify msg_target_template.txt and run gen_target.sh instead.
3+
4+
extern crate lightning;
5+
6+
use lightning::ln::msgs;
7+
use lightning::util::reset_rng_state;
8+
9+
use lightning::ln::msgs::{MsgEncodable, MsgDecodable};
10+
use lightning::util::ser::{Writer, Reader, Writeable, Readable};
11+
12+
mod utils;
13+
14+
#[inline]
15+
pub fn do_test(data: &[u8]) {
16+
reset_rng_state();
17+
test_msg_writeable!(msgs::AcceptChannel, data);
18+
}
19+
20+
#[cfg(feature = "afl")]
21+
#[macro_use] extern crate afl;
22+
#[cfg(feature = "afl")]
23+
fn main() {
24+
fuzz!(|data| {
25+
do_test(data);
26+
});
27+
}
28+
29+
#[cfg(feature = "honggfuzz")]
30+
#[macro_use] extern crate honggfuzz;
31+
#[cfg(feature = "honggfuzz")]
32+
fn main() {
33+
loop {
34+
fuzz!(|data| {
35+
do_test(data);
36+
});
37+
}
38+
}
39+
40+
extern crate hex;
41+
#[cfg(test)]
42+
mod tests {
43+
#[test]
44+
fn duplicate_crash() {
45+
super::do_test(&::hex::decode("00").unwrap());
46+
}
47+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// This file is auto-generated by gen_target.sh based on msg_target_template.txt
2+
// To modify it, modify msg_target_template.txt and run gen_target.sh instead.
3+
4+
extern crate lightning;
5+
6+
use lightning::ln::msgs;
7+
use lightning::util::reset_rng_state;
8+
9+
use lightning::ln::msgs::{MsgEncodable, MsgDecodable};
10+
use lightning::util::ser::{Writer, Reader, Writeable, Readable};
11+
12+
mod utils;
13+
14+
#[inline]
15+
pub fn do_test(data: &[u8]) {
16+
reset_rng_state();
17+
test_msg_writeable!(msgs::AnnouncementSignatures, data);
18+
}
19+
20+
#[cfg(feature = "afl")]
21+
#[macro_use] extern crate afl;
22+
#[cfg(feature = "afl")]
23+
fn main() {
24+
fuzz!(|data| {
25+
do_test(data);
26+
});
27+
}
28+
29+
#[cfg(feature = "honggfuzz")]
30+
#[macro_use] extern crate honggfuzz;
31+
#[cfg(feature = "honggfuzz")]
32+
fn main() {
33+
loop {
34+
fuzz!(|data| {
35+
do_test(data);
36+
});
37+
}
38+
}
39+
40+
extern crate hex;
41+
#[cfg(test)]
42+
mod tests {
43+
#[test]
44+
fn duplicate_crash() {
45+
super::do_test(&::hex::decode("00").unwrap());
46+
}
47+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// This file is auto-generated by gen_target.sh based on msg_target_template.txt
2+
// To modify it, modify msg_target_template.txt and run gen_target.sh instead.
3+
4+
extern crate lightning;
5+
6+
use lightning::ln::msgs;
7+
use lightning::util::reset_rng_state;
8+
9+
use lightning::ln::msgs::{MsgEncodable, MsgDecodable};
10+
use lightning::util::ser::{Writer, Reader, Writeable, Readable};
11+
12+
mod utils;
13+
14+
#[inline]
15+
pub fn do_test(data: &[u8]) {
16+
reset_rng_state();
17+
test_msg_writeable!(msgs::ChannelReestablish, data);
18+
}
19+
20+
#[cfg(feature = "afl")]
21+
#[macro_use] extern crate afl;
22+
#[cfg(feature = "afl")]
23+
fn main() {
24+
fuzz!(|data| {
25+
do_test(data);
26+
});
27+
}
28+
29+
#[cfg(feature = "honggfuzz")]
30+
#[macro_use] extern crate honggfuzz;
31+
#[cfg(feature = "honggfuzz")]
32+
fn main() {
33+
loop {
34+
fuzz!(|data| {
35+
do_test(data);
36+
});
37+
}
38+
}
39+
40+
extern crate hex;
41+
#[cfg(test)]
42+
mod tests {
43+
#[test]
44+
fn duplicate_crash() {
45+
super::do_test(&::hex::decode("00").unwrap());
46+
}
47+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// This file is auto-generated by gen_target.sh based on msg_target_template.txt
2+
// To modify it, modify msg_target_template.txt and run gen_target.sh instead.
3+
4+
extern crate lightning;
5+
6+
use lightning::ln::msgs;
7+
use lightning::util::reset_rng_state;
8+
9+
use lightning::ln::msgs::{MsgEncodable, MsgDecodable};
10+
use lightning::util::ser::{Writer, Reader, Writeable, Readable};
11+
12+
mod utils;
13+
14+
#[inline]
15+
pub fn do_test(data: &[u8]) {
16+
reset_rng_state();
17+
test_msg_writeable!(msgs::ClosingSigned, data);
18+
}
19+
20+
#[cfg(feature = "afl")]
21+
#[macro_use] extern crate afl;
22+
#[cfg(feature = "afl")]
23+
fn main() {
24+
fuzz!(|data| {
25+
do_test(data);
26+
});
27+
}
28+
29+
#[cfg(feature = "honggfuzz")]
30+
#[macro_use] extern crate honggfuzz;
31+
#[cfg(feature = "honggfuzz")]
32+
fn main() {
33+
loop {
34+
fuzz!(|data| {
35+
do_test(data);
36+
});
37+
}
38+
}
39+
40+
extern crate hex;
41+
#[cfg(test)]
42+
mod tests {
43+
#[test]
44+
fn duplicate_crash() {
45+
super::do_test(&::hex::decode("00").unwrap());
46+
}
47+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// This file is auto-generated by gen_target.sh based on msg_target_template.txt
2+
// To modify it, modify msg_target_template.txt and run gen_target.sh instead.
3+
4+
extern crate lightning;
5+
6+
use lightning::ln::msgs;
7+
use lightning::util::reset_rng_state;
8+
9+
use lightning::ln::msgs::{MsgEncodable, MsgDecodable};
10+
use lightning::util::ser::{Writer, Reader, Writeable, Readable};
11+
12+
mod utils;
13+
14+
#[inline]
15+
pub fn do_test(data: &[u8]) {
16+
reset_rng_state();
17+
test_msg_writeable!(msgs::CommitmentSigned, data);
18+
}
19+
20+
#[cfg(feature = "afl")]
21+
#[macro_use] extern crate afl;
22+
#[cfg(feature = "afl")]
23+
fn main() {
24+
fuzz!(|data| {
25+
do_test(data);
26+
});
27+
}
28+
29+
#[cfg(feature = "honggfuzz")]
30+
#[macro_use] extern crate honggfuzz;
31+
#[cfg(feature = "honggfuzz")]
32+
fn main() {
33+
loop {
34+
fuzz!(|data| {
35+
do_test(data);
36+
});
37+
}
38+
}
39+
40+
extern crate hex;
41+
#[cfg(test)]
42+
mod tests {
43+
#[test]
44+
fn duplicate_crash() {
45+
super::do_test(&::hex::decode("00").unwrap());
46+
}
47+
}

0 commit comments

Comments
 (0)