diff --git a/Corlib.Extensions/System/IO/Stream.cs b/Corlib.Extensions/System/IO/Stream.cs
index f3f6d16..21c53ca 100644
--- a/Corlib.Extensions/System/IO/Stream.cs
+++ b/Corlib.Extensions/System/IO/Stream.cs
@@ -1172,7 +1172,7 @@ static byte[] StructToBytes(TStruct value) {
public static void ReadBytes(this Stream @this, long position, byte[] buffer, SeekOrigin seekOrigin = SeekOrigin.Begin) {
Against.False(@this.CanRead);
- _SeekToPositionAndCheck(@this, position, buffer.Length, seekOrigin);
+ _SeekToPositionAndCheck(@this, position, (int)Math.Min(buffer.Length, @this.Length - position), seekOrigin);
_ReadBytesToArraySeekable(@this, buffer, 0, buffer.Length);
}
@@ -1188,7 +1188,7 @@ public static void ReadBytes(this Stream @this, long position, byte[] buffer, Se
/// A awaitable Task representing the operation
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Task ReadBytesAsync(this Stream @this, long position, byte[] buffer, SeekOrigin seekOrigin = SeekOrigin.Begin)
- => ReadBytesAsync(@this, position, buffer, 0, buffer.Length, seekOrigin);
+ => ReadBytesAsync(@this, position, buffer, 0, (int)Math.Min(buffer.Length, @this.Length - position), seekOrigin);
///
/// Reads async Bytes from a given position with a given SeekOrigin in the given buffer with an offset