From: Matt Corallo Date: Sun, 16 Apr 2023 21:57:20 +0000 (+0000) Subject: Fix deserialization of u16 arrays X-Git-Tag: v0.0.115~20^2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=7775356c390886b6db4985e3d520b17b5b74df6e;p=rust-lightning Fix deserialization of u16 arrays u16 arrays are used in the historical liquidity range tracker. Previously, we read them without applying the stride multiple, reading bytes repeatedly and at an offset, corrupting data as we go. This applies the correct stride multiplayer fixing the issue. --- diff --git a/lightning/src/util/ser.rs b/lightning/src/util/ser.rs index 366e6c8cb..8056f3bed 100644 --- a/lightning/src/util/ser.rs +++ b/lightning/src/util/ser.rs @@ -596,7 +596,7 @@ impl Readable for [u16; 8] { r.read_exact(&mut buf)?; let mut res = [0u16; 8]; for (idx, v) in res.iter_mut().enumerate() { - *v = (buf[idx] as u16) << 8 | (buf[idx + 1] as u16) + *v = (buf[idx*2] as u16) << 8 | (buf[idx*2 + 1] as u16) } Ok(res) }