websocketserver: Validate op field type

Could cause a crash by assuming `op` is always a number.

Closes #965
This commit is contained in:
tt2468 2022-07-25 08:00:48 -07:00
parent de40b53d77
commit b9a63603c7

View File

@ -444,6 +444,12 @@ void WebSocketServer::onMessage(websocketpp::connection_hdl hdl,
goto skipProcessing; goto skipProcessing;
} }
if (!incomingMessage["op"].is_number()) {
ret.closeCode = WebSocketCloseCode::UnknownOpCode;
ret.closeReason = "Your `op` is not a number.";
goto skipProcessing;
}
ProcessMessage(session, ret, incomingMessage["op"], incomingMessage["d"]); ProcessMessage(session, ret, incomingMessage["op"], incomingMessage["d"]);
skipProcessing: skipProcessing: