Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@
<data name="net_Websockets_ClientReceivedMaskedFrame" xml:space="preserve">
<value>The WebSocket server sent a masked frame.</value>
</data>
<data name="net_Websockets_ServerReceivedUnmaskedFrame" xml:space="preserve">
<value>The WebSocket client sent an unmasked frame.</value>
</data>
<data name="net_Websockets_ContinuationFromFinalFrame" xml:space="preserve">
<value>The WebSocket received a continuation frame from a previous final message.</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,11 @@ private async ValueTask CloseWithReceiveErrorAndThrowAsync(
// Consume the mask bytes
ConsumeFromBuffer(4);
}
else if (_isServer)
{
resultHeader = default;
return SR.net_Websockets_ServerReceivedUnmaskedFrame;
}

// Do basic validation of the header
switch (header.Opcode)
Expand Down
14 changes: 14 additions & 0 deletions src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,20 @@
client.SendAsync(Memory<byte>.Empty, WebSocketMessageType.Binary, WebSocketMessageFlags.EndOfMessage, default));
}

[Fact]
public async Task ReceiveAsync_ServerUnmaskedFrame_ThrowsWebSocketException()
{
byte[] frame = { 0x81, 0x05, 0x48, 0x65, 0x6C, 0x6C, 0x6F };
using var stream = new MemoryStream();
stream.Write(frame, 0, frame.Length);
stream.Position = 0;
using WebSocket websocket = WebSocket.CreateFromStream(stream, new WebSocketCreationOptions { IsServer = true });
WebSocketException exception = await Assert.ThrowsAsync<WebSocketException>(() =>
websocket.ReceiveAsync(new byte[5], CancellationToken.None));

Check failure on line 196 in src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs

View check run for this annotation

Azure Pipelines / runtime-dev-innerloop (Build Libraries Build freebsd x64 Debug)

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs#L196

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs(196,53): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'CancellationToken' does not exist in the current context

Check failure on line 196 in src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs

View check run for this annotation

Azure Pipelines / runtime (Build Libraries Build linux_musl arm Release)

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs#L196

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs(196,53): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'CancellationToken' does not exist in the current context

Check failure on line 196 in src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs

View check run for this annotation

Azure Pipelines / runtime (Build Libraries Build linux arm64 Debug)

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs#L196

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs(196,53): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'CancellationToken' does not exist in the current context

Check failure on line 196 in src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs

View check run for this annotation

Azure Pipelines / runtime (Build Libraries Build linux arm Release)

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs#L196

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs(196,53): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'CancellationToken' does not exist in the current context

Check failure on line 196 in src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs

View check run for this annotation

Azure Pipelines / runtime (Build Libraries Build linux_musl arm64 Release)

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs#L196

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs(196,53): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'CancellationToken' does not exist in the current context

Check failure on line 196 in src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs

View check run for this annotation

Azure Pipelines / runtime (Build Libraries Build linux_musl x64 Debug)

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs#L196

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs(196,53): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'CancellationToken' does not exist in the current context

Check failure on line 196 in src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs

View check run for this annotation

Azure Pipelines / runtime (Build Libraries Build linux x64 Debug)

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs#L196

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs(196,53): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'CancellationToken' does not exist in the current context

Check failure on line 196 in src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs

View check run for this annotation

Azure Pipelines / runtime (Build Libraries Build osx arm64 Debug)

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs#L196

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs(196,53): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'CancellationToken' does not exist in the current context

Check failure on line 196 in src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs

View check run for this annotation

Azure Pipelines / runtime (Build browser-wasm linux Release LibraryTests)

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs#L196

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs(196,53): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'CancellationToken' does not exist in the current context

Check failure on line 196 in src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs

View check run for this annotation

Azure Pipelines / runtime (Build browser-wasm linux Release LibraryTests_EAT)

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs#L196

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs(196,53): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'CancellationToken' does not exist in the current context

Check failure on line 196 in src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs

View check run for this annotation

Azure Pipelines / runtime (Build Libraries Build osx x64 Debug)

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs#L196

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs(196,53): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'CancellationToken' does not exist in the current context

Check failure on line 196 in src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs

View check run for this annotation

Azure Pipelines / runtime-dev-innerloop

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs#L196

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs(196,53): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'CancellationToken' does not exist in the current context
Assert.Equal(SR.net_Websockets_ServerReceivedUnmaskedFrame, exception.Message);

Check failure on line 197 in src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs

View check run for this annotation

Azure Pipelines / runtime-dev-innerloop (Build Libraries Build freebsd x64 Debug)

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs#L197

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs(197,26): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'SR' does not exist in the current context

Check failure on line 197 in src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs

View check run for this annotation

Azure Pipelines / runtime (Build Libraries Build linux_musl arm Release)

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs#L197

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs(197,26): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'SR' does not exist in the current context

Check failure on line 197 in src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs

View check run for this annotation

Azure Pipelines / runtime (Build Libraries Build linux arm64 Debug)

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs#L197

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs(197,26): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'SR' does not exist in the current context

Check failure on line 197 in src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs

View check run for this annotation

Azure Pipelines / runtime (Build Libraries Build linux arm Release)

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs#L197

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs(197,26): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'SR' does not exist in the current context

Check failure on line 197 in src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs

View check run for this annotation

Azure Pipelines / runtime (Build Libraries Build linux_musl arm64 Release)

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs#L197

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs(197,26): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'SR' does not exist in the current context

Check failure on line 197 in src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs

View check run for this annotation

Azure Pipelines / runtime (Build Libraries Build linux_musl x64 Debug)

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs#L197

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs(197,26): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'SR' does not exist in the current context

Check failure on line 197 in src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs

View check run for this annotation

Azure Pipelines / runtime (Build Libraries Build linux x64 Debug)

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs#L197

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs(197,26): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'SR' does not exist in the current context

Check failure on line 197 in src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs

View check run for this annotation

Azure Pipelines / runtime (Build Libraries Build osx arm64 Debug)

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs#L197

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs(197,26): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'SR' does not exist in the current context

Check failure on line 197 in src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs

View check run for this annotation

Azure Pipelines / runtime (Build browser-wasm linux Release LibraryTests)

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs#L197

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs(197,26): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'SR' does not exist in the current context

Check failure on line 197 in src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs

View check run for this annotation

Azure Pipelines / runtime (Build browser-wasm linux Release LibraryTests_EAT)

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs#L197

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs(197,26): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'SR' does not exist in the current context

Check failure on line 197 in src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs

View check run for this annotation

Azure Pipelines / runtime (Build Libraries Build osx x64 Debug)

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs#L197

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs(197,26): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'SR' does not exist in the current context

Check failure on line 197 in src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs

View check run for this annotation

Azure Pipelines / runtime-dev-innerloop

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs#L197

src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs(197,26): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'SR' does not exist in the current context
Assert.Equal(WebSocketState.Aborted, websocket.State);
Comment thread
jozkee marked this conversation as resolved.
}

public abstract class ExposeProtectedWebSocket : WebSocket
{
public static new bool IsStateTerminal(WebSocketState state) =>
Expand Down
Loading