X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Fonion_utils.rs;fp=lightning%2Fsrc%2Fln%2Fonion_utils.rs;h=f81c619d7353997c1019e60ac3b967da9b6ac1b0;hb=17ec697f8f09d608f6a3d2703ed4f4409773b4bf;hp=145eb8acbaed74c3b10f8fc26bf9af608d2b7329;hpb=39397d4e14ed87e62cf8f313de749b7b5785561e;p=rust-lightning diff --git a/lightning/src/ln/onion_utils.rs b/lightning/src/ln/onion_utils.rs index 145eb8ac..f81c619d 100644 --- a/lightning/src/ln/onion_utils.rs +++ b/lightning/src/ln/onion_utils.rs @@ -725,7 +725,8 @@ pub(crate) fn decode_next_hop, N: NextPa return Ok((msg, None)); // We are the final destination for this packet } else { let mut new_packet_bytes = N::new(hop_data.len()); - let read_pos = chacha_stream.read(new_packet_bytes.as_mut()).unwrap(); + let read_pos = hop_data.len() - chacha_stream.read.position() as usize; + chacha_stream.read_exact(&mut new_packet_bytes.as_mut()[..read_pos]).unwrap(); #[cfg(debug_assertions)] { // Check two things: