fix improper use of negative value 35/234535/2
authorSeonah Moon <seonah1.moon@samsung.com>
Wed, 27 May 2020 06:00:25 +0000 (15:00 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Wed, 27 May 2020 06:53:28 +0000 (15:53 +0900)
https://github.com/warmcat/libwebsockets/commit/bce4d762e5a6b912f5993fcf3c8ccf94a08c88ca

Change-Id: I5eab3a8b58acb23c0339d33109a7614c93e8e93a

lib/tls/openssl/openssl-ssl.c

index afe4f97854c5df9a97b3f05bdb9d203698539f9d..0ea77414e2c0c09025be5d96eb9858417deb8bdc 100644 (file)
@@ -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;