Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4afc43a

Browse filesBrowse files
authored
Update HTTPConnection.cpp fhessel#106 Possible Crash Fix
Prevent crash on WebSocket request to non-WebSocket node. fhessel#106
1 parent de1876c commit 4afc43a
Copy full SHA for 4afc43a

File tree

Expand file treeCollapse file tree

1 file changed

+11
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-3
lines changed

‎src/HTTPConnection.cpp

Copy file name to clipboardExpand all lines: src/HTTPConnection.cpp
+11-3Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -519,9 +519,17 @@ void HTTPConnection::loop() {
519519

520520
// Finally, after the handshake is done, we create the WebsocketHandler and change the internal state.
521521
if(websocketRequested) {
522-
_wsHandler = ((WebsocketNode*)resolvedResource.getMatchingNode())->newHandler();
523-
_wsHandler->initialize(this); // make websocket with this connection
524-
_connectionState = STATE_WEBSOCKET;
522+
HTTPNode *node = resolvedResource.getMatchingNode();
523+
524+
// Check for websocket request on non-websocket node:
525+
if (node == nullptr || node->_nodeType != HTTPNodeType::WEBSOCKET) {
526+
HTTPS_LOGW("Websocket request on non-websocket node rejected");
527+
raiseError(404, "Not Found");
528+
} else {
529+
_wsHandler = ((WebsocketNode *) node)->newHandler();
530+
_wsHandler->initialize(this); // make websocket with this connection
531+
_connectionState = STATE_WEBSOCKET;
532+
}
525533
} else {
526534
// Handling the request is done
527535
HTTPS_LOGD("Handler function done, request complete");

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.