Skip to content

Commit

Permalink
Merge pull request #1887 from UnderminersTeam/fix-string-bounds-checks
Browse files Browse the repository at this point in the history
Fix string reading bounds checks
  • Loading branch information
Miepee authored Aug 24, 2024
2 parents 6f470f8 + 4d2ef0b commit fe1b45b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion UndertaleModLib/Util/BufferBinaryReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion UndertaleModLib/Util/FileBinaryReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit fe1b45b

Please sign in to comment.