File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -436,6 +436,9 @@ impl<'tx> PeginData<'tx> {
436436 if pegin_witness. len ( ) != 6 {
437437 return Err ( "size not 6" ) ;
438438 }
439+ if pegin_witness[ 5 ] . len ( ) < 80 {
440+ return Err ( "merkle proof too short" ) ;
441+ }
439442
440443 Ok ( PeginData {
441444 outpoint : prevout,
@@ -2379,4 +2382,21 @@ mod tests {
23792382 Err ( encode:: Error :: ParseFailed ( "superfluous asset issuance" ) ) ,
23802383 ) ) ;
23812384 }
2385+
2386+ #[ test]
2387+ fn malformed_pegin ( ) {
2388+ let mut input: TxIn = hex_deserialize ! ( "\
2389+ 0004000000000000ffffffff0000040000c0c0c0c0c0c0c0c0c0000000000000\
2390+ 00805555555555555505c0c0c0c0c03fc0c0c0c0c0c0c0c0c0c0c0c00200ff01\
2391+ 0000000000fd0000000000000000010000000000ffffffffffffffff00000000\
2392+ 000000ff000000000000010000000000000000000001002d342d35313700\
2393+ ") ;
2394+ input. witness = hex_deserialize ! ( "\
2395+ 0000000608202020202020202020202020202020202020202020202020202020\
2396+ 2020202020202020202020202020202020202020202020202020202020202020\
2397+ 2020202020202020202020202020202020202020202020202020202020200000\
2398+ 00000000000000000000000000000002000400000000\
2399+ ") ;
2400+ assert ! ( input. pegin_data( ) . is_none( ) ) ;
2401+ }
23822402}
You can’t perform that action at this time.
0 commit comments