Skip to content

Commit

Permalink
Consider remote sending a frame after sending a close frame a protoco…
Browse files Browse the repository at this point in the history
…l error.

The websocket RFC explicitly states this is not allowed.
  • Loading branch information
najamelan committed Sep 12, 2019
1 parent bed9bd4 commit 87f825b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/protocol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,11 @@ impl WebSocketContext {
Stream: Read + Write,
{
if let Some(mut frame) = self.frame.read_frame(stream, self.config.max_frame_size)? {

if !self.state.can_read() {
return Err(Error::Protocol("Remote sent frame after having sent a Close Frame".into()));
}

// MUST be 0 unless an extension is negotiated that defines meanings
// for non-zero values. If a nonzero value is received and none of
// the negotiated extensions defines the meaning of such a nonzero
Expand Down Expand Up @@ -398,11 +403,6 @@ impl WebSocketContext {
}
}

OpCode::Data(_) if !self.state.can_read() => {
// No data processing while closing.
Ok(None)
}

OpCode::Data(data) => {
let fin = frame.header().is_final;
match data {
Expand Down

0 comments on commit 87f825b

Please sign in to comment.