[Libwebsockets] A couple of patches and a question

Peter Pentchev roam at ringlet.net
Sun Oct 2 01:25:09 CEST 2016


On Sun, Oct 02, 2016 at 02:19:47AM +0300, Peter Pentchev wrote:
> Hi,
> 
> Thanks for keeping libwebsockets going!
> 
> What do you think about the attached couple of patches?

Er, well, this would have come across a lot better with the patches
actually attached, wouldn't it now...  Note that they're against
the v2.0-stable branch, since that's what we're in the process of
packaging for Debian right now; I can redo them against master if
you'd like.

> The first one
> fixes a couple of typographical and grammatical errors, and the second
> one tries to catch up with OpenSSL 1.1's changes in functionality.
> Yes, the same part of the code had some ifdefs related to OpenSSL 1.1
> added before, but very soon after that, in the next prerelease,
> things changed again and the various cleanup functions were turned
> into no-ops and marked as deprecated, since everything seems to be done
> automatically now.  Hopefully now that 1.1 has been published and
> has seen a couple of bugfix patchlevel releases, the interface should
> remain stable.
> 
> I also have a question that was raised by running cppcheck over
> the libwebsockets source: what is the lws_ssl_capable_write() function
> supposed to do in the LWS_USE_MBEDTLS case?  The ifdefs around
> the actual SSL library functions do not seem to do anything in
> that case, which leaves the value of the "n" variable undefined,
> not to mention no real work has been done, nothing has been written
> anywhere.  So, I guess, either assign something to n to explicitly
> signal your intention or, I don't know, make the function actually
> do something? :)
> 
> Thanks again for your work on libwebsockets!

G'luck,
Peter

-- 
Peter Pentchev  roam at ringlet.net roam at FreeBSD.org pp at storpool.com
PGP key:        http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13
-------------- next part --------------
From 59b6c7bd86487f64c0658a3628dc1fb588672bc6 Mon Sep 17 00:00:00 2001
From: Peter Pentchev <roam at ringlet.net>
Date: Sun, 2 Oct 2016 02:21:03 +0300
Subject: [PATCH 1/2] Fix some typographical and grammatical errors.

---
 CMakeLists.txt                 | 2 +-
 README.build.md                | 4 ++--
 README.coding.md               | 2 +-
 README.lwsws.md                | 2 +-
 README.test-apps.md            | 8 ++++----
 lib/http2.c                    | 2 +-
 lib/libwebsockets.c            | 4 ++--
 lib/libwebsockets.h            | 2 +-
 lib/lws-plat-unix.c            | 2 +-
 lib/private-libwebsockets.h    | 2 +-
 lib/server.c                   | 4 ++--
 lib/service.c                  | 2 +-
 test-server/attack.sh          | 2 +-
 test-server/test-echo.c        | 2 +-
 test-server/test-ping.c        | 2 +-
 test-server/test-server-http.c | 2 +-
 16 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 57e1abe..4cea098 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -379,7 +379,7 @@ if (NOT LWS_HAVE_inline)
 	endif()
 endif()
 
-# Put the libaries and binaries that get built into directories at the
+# Put the libraries and binaries that get built into directories at the
 # top of the build tree rather than in hard-to-find leaf directories. 
 SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
 SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
diff --git a/README.build.md b/README.build.md
index 0b8a90b..b11a487 100644
--- a/README.build.md
+++ b/README.build.md
@@ -225,11 +225,11 @@ Setting compile options
 -----------------------
 
 To set compile time flags you can either use one of the CMake gui applications
-or do it via command line.
+or do it via the command line.
 
 Command line
 ------------
-To list avaialable options (ommit the H if you don't want the help text):
+To list available options (omit the H if you don't want the help text):
 
 	cmake -LH ..
 
diff --git a/README.coding.md b/README.coding.md
index 8415764..9d5e87a 100644
--- a/README.coding.md
+++ b/README.coding.md
@@ -21,7 +21,7 @@ allow up to that many connections, minus whatever other file descriptors are
 in use by the user code.
 
 If you want to restrict that allocation, or increase it, you can use ulimit or
-similar to change the avaiable number of file descriptors, and when restarted
+similar to change the available number of file descriptors, and when restarted
 **libwebsockets** will adapt accordingly.
 
 
diff --git a/README.lwsws.md b/README.lwsws.md
index cebc6b2..eb8df6b 100644
--- a/README.lwsws.md
+++ b/README.lwsws.md
@@ -241,7 +241,7 @@ Note: currently only a fixed set of mimetypes are supported.
 Other mount options
 -------------------
 
-1) When using a cgi:// protcol origin at a mountpoint, you may also give cgi environment variables specific to the mountpoint like this
+1) When using a cgi:// protocol origin at a mountpoint, you may also give cgi environment variables specific to the mountpoint like this
 
 ```
        {
diff --git a/README.test-apps.md b/README.test-apps.md
index 3b76052..b8ccc43 100644
--- a/README.test-apps.md
+++ b/README.test-apps.md
@@ -84,7 +84,7 @@ The test client supports SSL too, use
 $ libwebsockets-test-client localhost --ssl -s
 ```
 
-the -s tells it to accept the default selfsigned cert from the server,
+the -s tells it to accept the default self-signed cert from the server,
 otherwise it will strictly fail the connection if there is no CA cert to
 validate the server's certificate.
 
@@ -141,7 +141,7 @@ To test SSL/WSS client action, just run the client test with
 $ libwebsockets-test-client localhost --ssl
 ```
 
-By default the client test applet is set to accept selfsigned
+By default the client test applet is set to accept self-signed
 certificates used by the test server, this is indicated by the
 `use_ssl` var being set to `2`.  Set it to `1` to reject any server
 certificate that it doesn't have a trusted CA cert for.
@@ -192,7 +192,7 @@ Before you can even use the PING opcode that is part of the
 standard, you must complete a handshake with a specified
 protocol.  By default lws-mirror-protocol is used which is
 supported by the test server.  But if you are using it on
-another server, you can specify the protcol to handshake with
+another server, you can specify the protocol to handshake with
 by `--protocol=protocolname`
 
 
@@ -350,7 +350,7 @@ Autobahn Test Notes
 -------------------
 
 1) Autobahn tests the user code + lws implementation.  So to get the same
-results, you need to follow test-echo.c in terms of user implmentation.
+results, you need to follow test-echo.c in terms of user implementation.
 
 2) Some of the tests make no sense for Libwebsockets to support and we fail them.
 
diff --git a/lib/http2.c b/lib/http2.c
index 2f3ea01..ea94940 100644
--- a/lib/http2.c
+++ b/lib/http2.c
@@ -479,7 +479,7 @@ int lws_http2_do_pps_send(struct lws_context *context, struct lws *wsi)
 			wsi->u.http.fd = LWS_INVALID_FILE;
 
 			if (lws_is_ssl(lws_http2_get_network_wsi(wsi))) {
-				lwsl_info("skipping nonexistant ssl upgrade headers\n");
+				lwsl_info("skipping nonexistent ssl upgrade headers\n");
 				break;
 			}
 
diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c
index 8562290..6c3598c 100755
--- a/lib/libwebsockets.c
+++ b/lib/libwebsockets.c
@@ -1321,7 +1321,7 @@ lws_get_fops(struct lws_context *context)
 }
 
 /**
- * lws_get_context - Allow geting lws_context from a Websocket connection
+ * lws_get_context - Allow getting lws_context from a Websocket connection
  * instance
  *
  * With this function, users can access context in the callback function.
@@ -1735,7 +1735,7 @@ lws_create_basic_wsi(struct lws_context *context, int tsi)
 	new_wsi->pending_timeout = NO_PENDING_TIMEOUT;
 	new_wsi->rxflow_change_to = LWS_RXFLOW_ALLOW;
 
-	/* intialize the instance struct */
+	/* initialize the instance struct */
 
 	new_wsi->state = LWSS_CGI;
 	new_wsi->mode = LWSCM_CGI;
diff --git a/lib/libwebsockets.h b/lib/libwebsockets.h
index 5183090..3b34ffd 100644
--- a/lib/libwebsockets.h
+++ b/lib/libwebsockets.h
@@ -1012,7 +1012,7 @@ struct lws_extension;
  *
  *	LWS_CALLBACK_OPENSSL_LOAD_EXTRA_SERVER_VERIFY_CERTS: if configured for
  *		including OpenSSL support, this callback allows your user code
- *		to load extra certifcates into the server which allow it to
+ *		to load extra certificates into the server which allow it to
  *		verify the validity of certificates returned by clients.  @user
  *		is the server's OpenSSL SSL_CTX*
  *
diff --git a/lib/lws-plat-unix.c b/lib/lws-plat-unix.c
index b430a78..612426c 100644
--- a/lib/lws-plat-unix.c
+++ b/lib/lws-plat-unix.c
@@ -538,7 +538,7 @@ lws_interface_to_sa(int ipv6, const char *ifname, struct sockaddr_in *addr,
 	freeifaddrs(ifr);
 
 	if (rc == -1) {
-		/* check if bind to IP adddress */
+		/* check if bind to IP address */
 #ifdef LWS_USE_IPV6
 		if (inet_pton(AF_INET6, ifname, &addr6->sin6_addr) == 1)
 			rc = 0;
diff --git a/lib/private-libwebsockets.h b/lib/private-libwebsockets.h
index 8102a73..dffecf4 100644
--- a/lib/private-libwebsockets.h
+++ b/lib/private-libwebsockets.h
@@ -627,7 +627,7 @@ struct lws_context_per_thread {
  *   vhostwide SSL context
  *   vhostwide proxy
  *
- * heirarchy:
+ * hierarchy:
  *
  * context -> vhost -> wsi
  *
diff --git a/lib/server.c b/lib/server.c
index 2f49882..e658b8e 100644
--- a/lib/server.c
+++ b/lib/server.c
@@ -1189,7 +1189,7 @@ lws_create_new_server_wsi(struct lws_vhost *vhost)
 	new_wsi->pending_timeout = NO_PENDING_TIMEOUT;
 	new_wsi->rxflow_change_to = LWS_RXFLOW_ALLOW;
 
-	/* intialize the instance struct */
+	/* initialize the instance struct */
 
 	new_wsi->state = LWSS_HTTP;
 	new_wsi->mode = LWSCM_HTTP_SERVING;
@@ -1533,7 +1533,7 @@ lws_server_socket_service(struct lws_context *context, struct lws *wsi,
 		    wsi->state == LWSS_HTTP_ISSUING_FILE ||
 		    wsi->state == LWSS_HTTP_HEADERS) {
 			if (!wsi->u.hdr.ah)
-				/* no autoservice beacuse we will do it next */
+				/* no autoservice because we will do it next */
 				if (lws_header_table_attach(wsi, 0))
 					goto try_pollout;
 
diff --git a/lib/service.c b/lib/service.c
index f6ad73a..1b3fc40 100644
--- a/lib/service.c
+++ b/lib/service.c
@@ -923,7 +923,7 @@ drain:
 			lws_change_pollfd(wsi, LWS_POLLIN, 0);
 
 			/* let user code know, he'll usually ask for writeable
-			 * callback and drain / reenable it there
+			 * callback and drain / re-enable it there
 			 */
 			if (user_callback_handle_rxflow(
 					wsi->protocol->callback,
diff --git a/test-server/attack.sh b/test-server/attack.sh
index bf4823e..19dff02 100755
--- a/test-server/attack.sh
+++ b/test-server/attack.sh
@@ -233,7 +233,7 @@ check default
 check
 
 echo
-echo "---- nonexistant file"
+echo "---- nonexistent file"
 rm -f /tmp/lwscap
 echo -e "GET /nope HTTP/1.1\x0d\x0a\x0d\x0a" | nc $SERVER $PORT | sed '1,/^\r$/d'> /tmp/lwscap
 check media
diff --git a/test-server/test-echo.c b/test-server/test-echo.c
index 75390f6..992acef 100644
--- a/test-server/test-echo.c
+++ b/test-server/test-echo.c
@@ -182,7 +182,7 @@ static struct lws_protocols protocols[] = {
 	/* first protocol must always be HTTP handler */
 
 	{
-		"",		/* name - can be overriden with -e */
+		"",		/* name - can be overridden with -e */
 		callback_echo,
 		sizeof(struct per_session_data__echo),	/* per_session_data_size */
 		MAX_ECHO_PAYLOAD,
diff --git a/test-server/test-ping.c b/test-server/test-ping.c
index 65ab942..d0be370 100644
--- a/test-server/test-ping.c
+++ b/test-server/test-ping.c
@@ -396,7 +396,7 @@ int main(int argc, char **argv)
 		case 'r':
 			clients = atoi(optarg);
 			if (clients > MAX_PING_CLIENTS || clients < 1) {
-				fprintf(stderr, "Max clients supportd = %d\n",
+				fprintf(stderr, "Max clients supported = %d\n",
 							      MAX_PING_CLIENTS);
 				return 1;
 			}
diff --git a/test-server/test-server-http.c b/test-server/test-server-http.c
index 215dc22..09a0de4 100644
--- a/test-server/test-server-http.c
+++ b/test-server/test-server-http.c
@@ -279,7 +279,7 @@ int callback_http(struct lws *wsi, enum lws_callback_reasons reason, void *user,
 						     LWS_O_RDONLY);
 
 			if (pss->fd == LWS_INVALID_FILE) {
-				lwsl_err("faild to open file %s\n", leaf_path);
+				lwsl_err("failed to open file %s\n", leaf_path);
 				return -1;
 			}
 
-- 
2.9.3

-------------- next part --------------
From 43c91558200df9a80cec7366df94a0ae1122a639 Mon Sep 17 00:00:00 2001
From: Peter Pentchev <roam at ringlet.net>
Date: Sun, 2 Oct 2016 02:21:20 +0300
Subject: [PATCH 2/2] Remove the cleanup functions with OpenSSL 1.1.

The thread support in OpenSSL has been rewritten almost completely
and the cleanup functions are now executed automatically.
---
 lib/ssl.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/ssl.c b/lib/ssl.c
index 685584e..939ee0e 100644
--- a/lib/ssl.c
+++ b/lib/ssl.c
@@ -194,6 +194,7 @@ lws_ssl_destroy(struct lws_vhost *vhost)
 	if (!vhost->user_supplied_ssl_ctx && vhost->ssl_client_ctx)
 		SSL_CTX_free(vhost->ssl_client_ctx);
 
+#if (OPENSSL_VERSION_NUMBER < 0x10100006L)
 #if (OPENSSL_VERSION_NUMBER < 0x01000000) || defined(USE_WOLFSSL)
 	ERR_remove_state(0);
 #else
@@ -210,6 +211,7 @@ lws_ssl_destroy(struct lws_vhost *vhost)
 	CRYPTO_cleanup_all_ex_data();
 #endif
 #endif
+#endif
 }
 
 LWS_VISIBLE void
@@ -688,6 +690,7 @@ lws_ssl_context_destroy(struct lws_context *context)
 #else
 #if defined(LWS_USE_MBEDTLS)
 #else
+#if (OPENSSL_VERSION_NUMBER < 0x10100006L)
 #if (OPENSSL_VERSION_NUMBER < 0x01000000) || defined(USE_WOLFSSL)
 	ERR_remove_state(0);
 #else
@@ -704,4 +707,5 @@ lws_ssl_context_destroy(struct lws_context *context)
 	CRYPTO_cleanup_all_ex_data();
 #endif
 #endif
+#endif
 }
-- 
2.9.3

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20161002/d0714ae6/attachment.sig>


More information about the Libwebsockets mailing list