Skip to content
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

10 sequential reads of SSL should only cause us to bomb out if all re… #3187

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/roles/ws/ops-ws.c
Original file line number Diff line number Diff line change
Expand Up @@ -942,14 +942,15 @@ lws_is_ws_with_ext(struct lws *wsi)
#endif
}

#define SANITY_READS (10)
static int
rops_handle_POLLIN_ws(struct lws_context_per_thread *pt, struct lws *wsi,
struct lws_pollfd *pollfd)
{
unsigned int pending = 0;
struct lws_tokens ebuf;
char buffered = 0;
int n = 0, m, sanity = 10;
int n = 0, m, sanity = SANITY_READS, zero_len_reads = 0;
#if defined(LWS_WITH_HTTP2)
struct lws *wsi1;
#endif
Expand Down Expand Up @@ -1193,6 +1194,7 @@ rops_handle_POLLIN_ws(struct lws_context_per_thread *pt, struct lws *wsi,
/* we closed wsi */
return LWS_HPI_RET_WSI_ALREADY_DIED;
}
if (n == 0) zero_len_reads++;
//lws_buflist_describe(&wsi->buflist, wsi, __func__);
//lwsl_notice("%s: consuming %d / %d\n", __func__, n, ebuf.len);
if (ebuf.len < 0 ||
Expand Down Expand Up @@ -1246,7 +1248,7 @@ rops_handle_POLLIN_ws(struct lws_context_per_thread *pt, struct lws *wsi,
* Something has gone wrong, we are spinning...
* let's bail on this connection
*/
return LWS_HPI_RET_PLEASE_CLOSE_ME;
return zero_len_reads == SANITY_READS ? LWS_HPI_RET_PLEASE_CLOSE_ME : LWS_HPI_RET_HANDLED;
}

if (buffered && /* were draining, now nothing left */
Expand Down