File tree Expand file tree Collapse file tree 3 files changed +105
-1
lines changed
fuzz/fuzz_targets/msg_targets Expand file tree Collapse file tree 3 files changed +105
-1
lines changed Original file line number Diff line number Diff line change 1
- for target in CommitmentSigned FundingCreated FundingLocked FundingSigned OpenChannel RevokeAndACK Shutdown UpdateAddHTLC UpdateFailHTLC UpdateFailMalformedHTLC UpdateFee UpdateFulfillHTLC AcceptChannel ClosingSigned; do
1
+ for target in Ping Pong CommitmentSigned FundingCreated FundingLocked FundingSigned OpenChannel RevokeAndACK Shutdown UpdateAddHTLC UpdateFailHTLC UpdateFailMalformedHTLC UpdateFee UpdateFulfillHTLC AcceptChannel ClosingSigned; do
2
2
tn=$( echo $target | sed ' s/\([a-z0-9]\)\([A-Z]\)/\1_\L\2/g' )
3
3
fn=msg_$( echo $tn | tr ' [:upper:]' ' [:lower:]' ) _target.rs
4
4
cat msg_target_template.txt | sed s/MSG_TARGET/$target / > $fn
Original file line number Diff line number Diff line change
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
+
11
+ mod utils;
12
+ use utils:: slice_to_be16;
13
+
14
+ #[ inline]
15
+ pub fn do_test ( data : & [ u8 ] ) {
16
+ reset_rng_state ( ) ;
17
+ let mut read_pos = 0 ;
18
+ loop {
19
+ test_msg ! ( msgs:: Ping , data, read_pos) ;
20
+ }
21
+ }
22
+
23
+ #[ cfg( feature = "afl" ) ]
24
+ extern crate afl;
25
+ #[ cfg( feature = "afl" ) ]
26
+ fn main ( ) {
27
+ afl:: read_stdio_bytes ( |data| {
28
+ do_test ( & data) ;
29
+ } ) ;
30
+ }
31
+
32
+ #[ cfg( feature = "honggfuzz" ) ]
33
+ #[ macro_use] extern crate honggfuzz;
34
+ #[ cfg( feature = "honggfuzz" ) ]
35
+ fn main ( ) {
36
+ loop {
37
+ fuzz ! ( |data| {
38
+ do_test( data) ;
39
+ } ) ;
40
+ }
41
+ }
42
+
43
+ #[ cfg( test) ]
44
+ mod tests {
45
+ use utils:: extend_vec_from_hex;
46
+ #[ test]
47
+ fn duplicate_crash ( ) {
48
+ let mut a = Vec :: new ( ) ;
49
+ extend_vec_from_hex ( "00" , & mut a) ;
50
+ super :: do_test ( & a) ;
51
+ }
52
+ }
Original file line number Diff line number Diff line change
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
+
11
+ mod utils;
12
+ use utils:: slice_to_be16;
13
+
14
+ #[ inline]
15
+ pub fn do_test ( data : & [ u8 ] ) {
16
+ reset_rng_state ( ) ;
17
+ let mut read_pos = 0 ;
18
+ loop {
19
+ test_msg ! ( msgs:: Pong , data, read_pos) ;
20
+ }
21
+ }
22
+
23
+ #[ cfg( feature = "afl" ) ]
24
+ extern crate afl;
25
+ #[ cfg( feature = "afl" ) ]
26
+ fn main ( ) {
27
+ afl:: read_stdio_bytes ( |data| {
28
+ do_test ( & data) ;
29
+ } ) ;
30
+ }
31
+
32
+ #[ cfg( feature = "honggfuzz" ) ]
33
+ #[ macro_use] extern crate honggfuzz;
34
+ #[ cfg( feature = "honggfuzz" ) ]
35
+ fn main ( ) {
36
+ loop {
37
+ fuzz ! ( |data| {
38
+ do_test( data) ;
39
+ } ) ;
40
+ }
41
+ }
42
+
43
+ #[ cfg( test) ]
44
+ mod tests {
45
+ use utils:: extend_vec_from_hex;
46
+ #[ test]
47
+ fn duplicate_crash ( ) {
48
+ let mut a = Vec :: new ( ) ;
49
+ extend_vec_from_hex ( "00" , & mut a) ;
50
+ super :: do_test ( & a) ;
51
+ }
52
+ }
You can’t perform that action at this time.
0 commit comments