From 4d2ef0b62e2adbf56adc6460c48fe876a328190f Mon Sep 17 00:00:00 2001 From: colinator27 <17358554+colinator27@users.noreply.github.com> Date: Sat, 24 Aug 2024 15:18:55 -0400 Subject: [PATCH] Fix string reading bounds checks --- UndertaleModLib/Util/BufferBinaryReader.cs | 2 +- UndertaleModLib/Util/FileBinaryReader.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/UndertaleModLib/Util/BufferBinaryReader.cs b/UndertaleModLib/Util/BufferBinaryReader.cs index 17a12f3d9..f133739e5 100644 --- a/UndertaleModLib/Util/BufferBinaryReader.cs +++ b/UndertaleModLib/Util/BufferBinaryReader.cs @@ -286,7 +286,7 @@ public string ReadGMString() if (length < 0) throw new IOException("Invalid string length"); - if (chunkBuffer.Position + length + 1 >= _length) + if (chunkBuffer.Position + length + 1 > _length) throw new IOException("Reading out of chunk bounds"); string res; diff --git a/UndertaleModLib/Util/FileBinaryReader.cs b/UndertaleModLib/Util/FileBinaryReader.cs index 98db5e992..419ae9551 100644 --- a/UndertaleModLib/Util/FileBinaryReader.cs +++ b/UndertaleModLib/Util/FileBinaryReader.cs @@ -214,7 +214,7 @@ public string ReadGMString() if (length < 0) throw new IOException("Invalid string length"); - if (Stream.Position + length + 1 >= _length) + if (Stream.Position + length + 1 > _length) throw new IOException("Reading out of bounds"); string res;