From 34e25bffc554f491cd81e64d512acf85089976ca Mon Sep 17 00:00:00 2001 From: Seonah Moon Date: Wed, 27 May 2020 15:00:25 +0900 Subject: [PATCH] fix improper use of negative value https://github.com/warmcat/libwebsockets/commit/bce4d762e5a6b912f5993fcf3c8ccf94a08c88ca Change-Id: I5eab3a8b58acb23c0339d33109a7614c93e8e93a --- lib/tls/openssl/openssl-ssl.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/tls/openssl/openssl-ssl.c b/lib/tls/openssl/openssl-ssl.c index afe4f97..0ea7741 100644 --- a/lib/tls/openssl/openssl-ssl.c +++ b/lib/tls/openssl/openssl-ssl.c @@ -344,6 +344,7 @@ lws_ssl_info_callback(const SSL *ssl, int where, int ret) struct lws *wsi; struct lws_context *context; struct lws_ssl_info si; + int fd; #ifndef USE_WOLFSSL context = (struct lws_context *)SSL_CTX_get_ex_data( @@ -356,7 +357,12 @@ lws_ssl_info_callback(const SSL *ssl, int where, int ret) #endif if (!context) return; - wsi = wsi_from_fd(context, SSL_get_fd(ssl)); + + fd = SSL_get_fd(ssl); + if (fd < 0 || (fd - lws_plat_socket_offset()) < 0) + return; + + wsi = wsi_from_fd(context, fd); if (!wsi) return; -- 2.7.4