#15 - Validate ping frame size limits.

This commit is contained in:
Chris Ross 2014-10-22 16:25:22 -07:00
parent 4a5dbccb46
commit 207767a9b0
1 changed files with 9 additions and 0 deletions

View File

@ -299,6 +299,15 @@ namespace Microsoft.AspNet.WebSockets.Protocol
if (_frameInProgress.OpCode == Constants.OpCodes.PingFrame || _frameInProgress.OpCode == Constants.OpCodes.PongFrame)
{
if (_frameBytesRemaining > 125)
{
if (State == WebSocketState.Open)
{
await CloseOutputAsync(WebSocketCloseStatus.ProtocolError, "Invalid control frame size", cancellationToken);
Abort();
}
throw new InvalidOperationException("Control frame too large."); // TODO: WebSocketException
}
// Drain it, should be less than 125 bytes
await EnsureDataAvailableOrReadAsync((int)_frameBytesRemaining, cancellationToken);