New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
visit unregistered websocket handler will crash civetweb #901
Comments
What do you mean by "visit the wrong websocket address"? You try to open a websocket connection to an ws://host/mywebsock URL, where there is no handler for "/mywebsock" registered? There never was an handler for this URL or there was a handler but you unregistered it? |
Tried to open a websocket connection to an ws://host/mywebsock URL, but there is no handler for "/mywebsock" registered. |
Just checked with the current HEAD version as well as with V1.11, but did not see any crash. |
I played the trick during the compiling process by adding 'MG_LEGACY_INTERFACE' #ifndef MG_LEGACY_INTERFACE make lib WITH_CPP=1 WITH_WEBSOCKET=1 WITH_ZLIB=1 |
I added the MG_LEGACY_INTERFACE, fixed some compile issues (old LEGAGY_INTERFACEs are untested), and successfully tested it with embedded_cpp:
No crash. Probably you could turn off optimization, add debug information (use a debug build) to get line numbers. |
I walked around the crash by bypassing the block
changed to an undefined macro as below : The crash is no longer anymore |
Interesting you ran into this Anyway, this part of the code is declared "legacy" since August 19, 2015 - so this code should have been removed already, since the tests for this have already been removed. I will remove some of the code that has been declared legacy for 3+ years - this corresponds to the solution you have already found. |
The legacy code that might have caused this issue has been removed. |
version 1.11
Register WS handler by CivetServer::AddWebsocketHandler() is OK, visit the WB handler is OK.
But if visit the WRONG WS address, civetweb will crash, call stack:
handle_websocket_request.isra
handle_request
process_new_connection
worker_thread
start_thread
clone
The text was updated successfully, but these errors were encountered: