Skip to content

Commit afbdc5a

Browse files
authored
Add validation when setting linger option (#410)
***NO_CI***
1 parent 7e0da48 commit afbdc5a

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎nanoFramework.System.Net/Sockets/Socket.cs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,12 @@ public void SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName opti
909909
throw new ObjectDisposedException();
910910
}
911911

912+
// Linger option requires 8 bytes (enabled flag + linger time, 4 bytes each)
913+
if (optionName == SocketOptionName.Linger && optionValue.Length < 8)
914+
{
915+
throw new SocketException(SocketError.Fault);
916+
}
917+
912918
NativeSocket.setsockopt(this, (int)optionLevel, (int)optionName, optionValue);
913919
}
914920

0 commit comments

Comments
 (0)