From 7775356c390886b6db4985e3d520b17b5b74df6e Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sun, 16 Apr 2023 21:57:20 +0000 Subject: [PATCH] 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. --- lightning/src/util/ser.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) } -- 2.39.5