[Libwebsockets] handling of recv returning 0

vuko vuko at hackerspace.pl
Wed Mar 20 14:45:09 CET 2019


On 20.03.2019 14:20, Andy Green wrote:
> diff --git a/lib/roles/http/client/client.c 
> b/lib/roles/http/client/client.c
> index 9a1aa00d4..b0574e630 100644
> --- a/lib/roles/http/client/client.c
> +++ b/lib/roles/http/client/client.c
> @@ -637,14 +635,15 @@ lws_tls_server_accept(struct lws *wsi)
>          if (m == SSL_ERROR_SYSCALL || m == SSL_ERROR_SSL)
>                  return LWS_SSL_CAPABLE_ERROR;
> 
> -       if (m == SSL_ERROR_WANT_READ || SSL_want_read(wsi->tls.ssl)) {
> +       if (m == SSL_ERROR_WANT_READ ||
> +           (m != SSL_ERROR_ZERO_RETURN && SSL_want_read(wsi->tls.ssl))) {
>                  if (lws_change_pollfd(wsi, 0, LWS_POLLIN)) {
>                          lwsl_info("%s: WANT_READ change_pollfd failed\n",
>                                    __func__);
>                          return LWS_SSL_CAPABLE_ERROR;
>                  }
> 
> -               lwsl_info("SSL_ERROR_WANT_READ\n");
> +               lwsl_info("SSL_ERROR_WANT_READ: m %d\n", m);
>                  return LWS_SSL_CAPABLE_MORE_SERVICE_READ;
>          }
>          if (m == SSL_ERROR_WANT_WRITE || SSL_want_write(wsi->tls.ssl)) {
> 
> it's on current master. please see if it solves your situation on your 
> platform + tls library as well.

This works only fo SSL connections. Non SSL conections use 
lws_ssl_capable_read_no_ssl function that is missing zero return check.

I have reproduced it both on current master and 3.1 version.

-vuko


More information about the Libwebsockets mailing list