Skip to content

Commit

Permalink
🐛 Fix stack corruption (wrong plug return type)
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinbreiz committed Dec 4, 2023
1 parent fde10fb commit 4fe4515
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ public static int Read(NetworkStream aThis, byte[] buffer, int offset, int count
return _streamSocket.Receive(buffer, offset, count, 0);
}

public static int Write(NetworkStream aThis, byte[] buffer, int offset, int count)
public static void Write(NetworkStream aThis, byte[] buffer, int offset, int count)
{
Cosmos.HAL.Global.debugger.Send("NetworkStream - Write.");

return _streamSocket.Send(buffer, offset, count, 0);
_streamSocket.Send(buffer, offset, count, 0);
}

public static void Flush(NetworkStream aThis)
Expand Down
7 changes: 7 additions & 0 deletions source/Cosmos.System2_Plugs/System/Net/Sockets/SocketImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,13 @@ public static int Receive(Socket aThis, byte[] buffer, int offset, int size, Soc
{
Cosmos.HAL.Global.debugger.Send("Socket - Receive byte[].");

if (offset < 0 || size < 0 || (offset + size) > buffer.Length)
{
Cosmos.HAL.Global.debugger.Send("Socket - Invalid offset or size");

throw new ArgumentOutOfRangeException("Invalid offset or size");
}

while (StateMachine.Data == null || StateMachine.Data.Length == 0)
{
if (StateMachine.Status != Status.ESTABLISHED)
Expand Down

0 comments on commit 4fe4515

Please sign in to comment.