-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Description
oatpp-websocket/src/oatpp-websocket/WebSocket.cpp
Lines 202 to 219 in d95c8ee
void WebSocket::handleFrame(const Frame::Header& frameHeader) { | |
switch (frameHeader.opcode) { | |
case Frame::OPCODE_CONTINUATION: | |
if(m_lastOpcode < 0) { | |
throw std::runtime_error("[oatpp::web::protocol::websocket::WebSocket::handleFrame()]: Invalid communication state."); | |
} | |
readPayload(frameHeader, nullptr); | |
break; | |
case Frame::OPCODE_TEXT: | |
if(checkForContinuation(frameHeader)) { | |
readPayload(frameHeader, nullptr); | |
} else { | |
throw std::runtime_error("[oatpp::web::protocol::websocket::WebSocket::handleFrame()]: Invalid communication state. OPCODE_CONTINUATION expected"); | |
} | |
break; | |
In the above code, the
m_lastOpcode
member is not updated when processing a frame with opcode=Frame::OPCODE_CONTINUATION
and fin=true
, so when processing Frame::OPCODE_TEXT
for the next frame, checkForContinuation()
returns false
and throws an exception. This results in a service disconnection.oatpp-websocket/src/oatpp-websocket/WebSocket.cpp
Lines 58 to 68 in d95c8ee
bool WebSocket::checkForContinuation(const Frame::Header& frameHeader) { | |
if(m_lastOpcode == Frame::OPCODE_TEXT || m_lastOpcode == Frame::OPCODE_BINARY) { | |
return false; | |
} | |
if(frameHeader.fin) { | |
m_lastOpcode = -1; | |
} else { | |
m_lastOpcode = frameHeader.opcode; | |
} | |
return true; | |
} |
The same problem exists with asynchronous implementations
Metadata
Metadata
Assignees
Labels
No labels