Skip to content

Commit f53a5d3

Browse files
catenacybervictorjulien
authored andcommitted
websocket: check pdu opcode for reassembly
Ticket: 8413 RFC 6455 Section 5.4 states Control frames (see Section 5.5) MAY be injected in the middle of a fragmented message. Control frames are identified by opcodes where the most significant bit of the opcode is 1. (cherry picked from commit 2fa1005)
1 parent c479a80 commit f53a5d3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

rust/src/websocket/websocket.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ impl WebSocketState {
220220
(&mut self.c2s_buf, &mut self.c2s_dec)
221221
};
222222
let mut compress = pdu.compress;
223-
if !buf.data.is_empty() || !pdu.fin {
223+
if pdu.opcode < 8 && (!buf.data.is_empty() || !pdu.fin) {
224224
if buf.data.is_empty() {
225225
buf.compress = pdu.compress;
226226
}
@@ -234,7 +234,7 @@ impl WebSocketState {
234234
}
235235
}
236236
tx.pdu = pdu;
237-
if tx.pdu.fin && !buf.data.is_empty() {
237+
if tx.pdu.opcode < 8 && tx.pdu.fin && !buf.data.is_empty() {
238238
// the final PDU gets the full reassembled payload
239239
compress = buf.compress;
240240
std::mem::swap(&mut tx.pdu.payload, &mut buf.data);

0 commit comments

Comments
 (0)