From d1958ee2eae9cb1ef683fccc30a5eecec6567a40 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Wed, 18 Nov 2020 07:55:49 +0000 Subject: [PATCH] sspc: check for client handle use before CREATING When ss is proxied, the handle CREATING state is deferred until the handle links up to the proxy. So user code should only start using it when it sees CREATING. If it tries to use it before then, we won'tget anywhere but we should make sure not to crash on the NULL proxy link cwsi. --- lib/secure-streams/secure-streams-client.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/secure-streams/secure-streams-client.c b/lib/secure-streams/secure-streams-client.c index cfc7c956a..b55301703 100644 --- a/lib/secure-streams/secure-streams-client.c +++ b/lib/secure-streams/secure-streams-client.c @@ -589,8 +589,8 @@ lws_sspc_request_tx_len(lws_sspc_handle_t *h, unsigned long len) /* * for client conns, they cannot even complete creation of the handle * without the onwared connection to the proxy, it's not legal to start - * using it until it's operation and has the onward connection (and has - * called CREATED state) + * using it until it's operation and has the onward connection (and the + * link has called CREATED state) */ if (!h) @@ -613,7 +613,8 @@ lws_sspc_request_tx_len(lws_sspc_handle_t *h, unsigned long len) * will request again. */ - lws_callback_on_writable(h->cwsi); + if (h->cwsi) + lws_callback_on_writable(h->cwsi); return LWSSSSRET_OK; } @@ -786,6 +787,9 @@ lws_sspc_get_est_peer_tx_credit(struct lws_sspc_handle *h) void lws_sspc_start_timeout(struct lws_sspc_handle *h, unsigned int timeout_ms) { + if (!h->cwsi) + /* we can't fulfil it */ + return; h->timeout_ms = (uint32_t)timeout_ms; h->pending_timeout_update = 1; lws_callback_on_writable(h->cwsi);