From 786e9dad9487eafd1319b70a628b8d917b45821c Mon Sep 17 00:00:00 2001 From: Cain <75994858+cainthebest@users.noreply.github.com> Date: Sat, 7 Sep 2024 00:53:21 +0100 Subject: [PATCH] fix(buf): use correct len fn on OOB check --- crates/lib/src/buffer.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/lib/src/buffer.rs b/crates/lib/src/buffer.rs index 549fabf..581ce8f 100644 --- a/crates/lib/src/buffer.rs +++ b/crates/lib/src/buffer.rs @@ -146,10 +146,10 @@ impl<'a, B: ByteOrder> Buffer<'a, B> { /// Returns a `BufferError` if there is an error decoding the string. pub fn read_string(&mut self, until: Option) -> GDResult { // Check if the cursor is out of bounds. - if self.cursor > self.remaining_length() { + if self.cursor > self.data_length() { return Err(PacketUnderflow.context(format!( "Cursor position {} is out of bounds when reading string. Buffer length: {}", - self.cursor, self.data.len() + self.cursor, self.data_length() ))); }