Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 7 additions & 0 deletions eng/install-native-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ case "$os" in
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
# Skip brew update for now, see https://github.com/actions/setup-python/issues/577
# brew update --preinstall

# Remove Homebrew LLVM if present. The CI runner image may ship with a
# Homebrew LLVM whose libraries (e.g., libunwind.dylib) are the wrong
# architecture or conflict with the Apple SDK, breaking native linking.
# The build uses Apple clang from /usr/bin/clang exclusively.
brew uninstall --ignore-dependencies llvm 2>/dev/null || true

brew bundle --no-upgrade --file "$(dirname "$0")/Brewfile"
Comment on lines +48 to 54
;;

Expand Down
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 @@ -1366,6 +1366,11 @@ private async ValueTask CloseWithReceiveErrorAndThrowAsync(
// Consume the mask bytes
ConsumeFromBuffer(4);
}
else if (_isServer)
{
resultHeader = default;
return SR.net_Websockets_ServerReceivedUnmaskedFrame;
}
Comment on lines +1369 to +1373

// 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 @@ -182,6 +182,20 @@ public async Task ThrowWhenContinuationWithDifferentCompressionFlags()
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));
Assert.Equal(SR.net_Websockets_ServerReceivedUnmaskedFrame, exception.Message);
Assert.Equal(WebSocketState.Aborted, websocket.State);
}

[Fact]
public async Task ReceiveAsync_WhenDisposedInParallel_DoesNotGetStuck()
{
Expand Down
Loading