]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Fix fee addition overflow in get_route 2018-07-route-fuzz-fix-1
authorMatt Corallo <git@bluematt.me>
Wed, 25 Jul 2018 21:45:03 +0000 (17:45 -0400)
committerMatt Corallo <git@bluematt.me>
Wed, 25 Jul 2018 22:10:46 +0000 (18:10 -0400)
src/ln/router.rs

index f30eb7912792df24f1dd6bcedae86cadb2e8f69a..bbd9cdadaf33279617b3173e383c220cbea2c800 100644 (file)
@@ -429,8 +429,9 @@ impl Router {
                                //TODO: Explore simply adding fee to hit htlc_minimum_msat
                                if $starting_fee_msat as u64 + final_value_msat > $directional_info.htlc_minimum_msat {
                                        let proportional_fee_millions = ($starting_fee_msat + final_value_msat).checked_mul($directional_info.fee_proportional_millionths as u64);
-                                       if let Some(proportional_fee) = proportional_fee_millions {
-                                               let new_fee = $directional_info.fee_base_msat as u64 + proportional_fee / 1000000;
+                                       if let Some(new_fee) = proportional_fee_millions.and_then(|part| {
+                                                       ($directional_info.fee_base_msat as u64).checked_add(part / 1000000) })
+                                       {
                                                let mut total_fee = $starting_fee_msat as u64;
                                                let mut hm_entry = dist.entry(&$directional_info.src_node_id);
                                                let old_entry = hm_entry.or_insert_with(|| {