From d1fa3dcfa862fe84704ca9df34f89905734af601 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Tue, 14 Jul 2020 19:40:11 +0100 Subject: [PATCH] ws: correctly handle ESTABLISHED rejecting connection https://github.com/warmcat/libwebsockets/issues/1973 --- CMakeLists.txt | 2 +- lib/core-net/dummy-callback.c | 3 ++- lib/roles/ws/server-ws.c | 5 ++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d0d3ea668..f309fa174 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -327,7 +327,7 @@ set(PACKAGE "libwebsockets") set(CPACK_PACKAGE_NAME "${PACKAGE}") set(CPACK_PACKAGE_VERSION_MAJOR "4") set(CPACK_PACKAGE_VERSION_MINOR "0") -set(CPACK_PACKAGE_VERSION_PATCH "21") +set(CPACK_PACKAGE_VERSION_PATCH "22") set(CPACK_PACKAGE_RELEASE 1) set(CPACK_GENERATOR "RPM") set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") diff --git a/lib/core-net/dummy-callback.c b/lib/core-net/dummy-callback.c index 77e2ab12c..f0809f628 100644 --- a/lib/core-net/dummy-callback.c +++ b/lib/core-net/dummy-callback.c @@ -112,7 +112,8 @@ lws_callback_ws_proxy(struct lws *wsi, enum lws_callback_reasons reason, if (!wsi->h1_ws_proxied || !wsi->parent) break; - lws_process_ws_upgrade2(wsi->parent); + if (lws_process_ws_upgrade2(wsi->parent)) + return -1; #if defined(LWS_WITH_HTTP2) if (wsi->parent->mux_substream) diff --git a/lib/roles/ws/server-ws.c b/lib/roles/ws/server-ws.c index 6fc4d1409..16617a12f 100644 --- a/lib/roles/ws/server-ws.c +++ b/lib/roles/ws/server-ws.c @@ -376,7 +376,10 @@ lws_process_ws_upgrade2(struct lws *wsi) break; } - lws_server_init_wsi_for_ws(wsi); + if (lws_server_init_wsi_for_ws(wsi)) { + lwsl_notice("%s: user ESTABLISHED failed connection\n", __func__); + return 1; + } lwsl_parser("accepted v%02d connection\n", wsi->ws->ietf_spec_revision); #if defined(LWS_WITH_ACCESS_LOG)