diff --git a/include/libwebsockets/lws-adopt.h b/include/libwebsockets/lws-adopt.h index 4c5e59a0a..1f0cfb846 100644 --- a/include/libwebsockets/lws-adopt.h +++ b/include/libwebsockets/lws-adopt.h @@ -88,7 +88,7 @@ struct lws_udp { }; #endif -/* +/** * lws_adopt_descriptor_vhost() - adopt foreign socket or file descriptor * if socket descriptor, should already have been accepted from listen socket * diff --git a/lib/plat/optee/lws-plat-optee.c b/lib/plat/optee/lws-plat-optee.c index 7e0dfa1fe..7103adc16 100644 --- a/lib/plat/optee/lws-plat-optee.c +++ b/lib/plat/optee/lws-plat-optee.c @@ -93,9 +93,11 @@ void lwsl_emit_optee(int level, const char *line) n = strlen(line); if ((unsigned int)n > sizeof(linecp) - 1) n = sizeof(linecp) - 1; - if (n) + if (n) { memcpy(linecp, line, n - 1); - linecp[n - 1] = '\0'; + linecp[n - 1] = '\0'; + } else + linecp[0] = '\0'; EMSG("%c%s%s%s%c[0m", 27, colours[m], buf, linecp, 27); } diff --git a/lib/plat/unix/unix-service.c b/lib/plat/unix/unix-service.c index dce2c0588..2a23570bf 100644 --- a/lib/plat/unix/unix-service.c +++ b/lib/plat/unix/unix-service.c @@ -141,7 +141,11 @@ _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi) m |= pt->context->tls_ops->fake_POLLIN_for_buffered(pt); #endif - if (!m && !n) { /* nothing to do */ + if ( +#if (defined(LWS_ROLE_WS) && !defined(LWS_WITHOUT_EXTENSIONS)) || defined(LWS_WITH_TLS) + !m && +#endif + !n) { /* nothing to do */ lws_service_fd_tsi(context, NULL, tsi); lws_service_do_ripe_rxflow(pt); diff --git a/lib/tls/mbedtls/wrapper/platform/ssl_pm.c b/lib/tls/mbedtls/wrapper/platform/ssl_pm.c index 654d1423a..4e6b45742 100755 --- a/lib/tls/mbedtls/wrapper/platform/ssl_pm.c +++ b/lib/tls/mbedtls/wrapper/platform/ssl_pm.c @@ -884,11 +884,21 @@ SSL *SSL_SSL_from_mbedtls_ssl_context(mbedtls_ssl_context *msc) void SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx) { -#if defined(LWS_HAVE_mbedtls_ssl_set_hs_authmode) +#if defined(LWS_HAVE_mbedtls_ssl_set_hs_authmode) || \ + defined(LWS_HAVE_mbedtls_ssl_set_hs_ca_chain) || \ + defined(LWS_HAVE_mbedtls_ssl_set_hs_own_cert) struct ssl_pm *ssl_pm = ssl->ssl_pm; +#endif +#if defined(LWS_HAVE_mbedtls_ssl_set_hs_own_cert) struct x509_pm *x509_pm = (struct x509_pm *)ctx->cert->x509->x509_pm; +#endif +#if defined(LWS_HAVE_mbedtls_ssl_set_hs_ca_chain) struct x509_pm *x509_pm_ca = (struct x509_pm *)ctx->client_CA->x509_pm; +#endif +#if defined(LWS_HAVE_mbedtls_ssl_set_hs_own_cert) struct pkey_pm *pkey_pm = (struct pkey_pm *)ctx->cert->pkey->pkey_pm; +#endif +#if defined(LWS_HAVE_mbedtls_ssl_set_hs_authmode) int mode; #endif @@ -908,8 +918,6 @@ void SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx) mode = MBEDTLS_SSL_VERIFY_NONE; #endif - // printf("ssl: %p, client ca x509_crt %p, mbedtls mode %d\n", ssl, x509_pm_ca->x509_crt, mode); - /* apply new ctx cert to ssl */ ssl->verify_mode = ctx->verify_mode; diff --git a/minimal-examples/api-tests/api-test-jose/jwe.c b/minimal-examples/api-tests/api-test-jose/jwe.c index e61f8eb74..412548b27 100644 --- a/minimal-examples/api-tests/api-test-jose/jwe.c +++ b/minimal-examples/api-tests/api-test-jose/jwe.c @@ -133,8 +133,6 @@ test_jwe_a1(struct lws_context *context) /* we require a JOSE-formatted header to do the encryption */ - if (temp_len < 256) - goto bail; jwe.jws.map.buf[LJWS_JOSE] = temp; jwe.jws.map.len[LJWS_JOSE] = lws_snprintf(temp, temp_len, "{\"alg\":\"%s\",\"enc\":\"%s\"}", "RSA-OAEP", "A256GCM"); @@ -1979,8 +1977,6 @@ test_akw_encrypt(struct lws_context *context, const char *test_name, /* we require a JOSE-formatted header to do the encryption */ - if (temp_len < 256) - goto bail; jwe.jws.map.buf[LJWS_JOSE] = temp; jwe.jws.map.len[LJWS_JOSE] = lws_snprintf(temp, temp_len, "{\"alg\":\"%s\", \"enc\":\"%s\"}", alg, enc); diff --git a/minimal-examples/http-server/minimal-http-server-deaddrop/mount-origin/deaddrop.js b/minimal-examples/http-server/minimal-http-server-deaddrop/mount-origin/deaddrop.js index 308c578d0..ebb6e12fa 100644 --- a/minimal-examples/http-server/minimal-http-server-deaddrop/mount-origin/deaddrop.js +++ b/minimal-examples/http-server/minimal-http-server-deaddrop/mount-origin/deaddrop.js @@ -19,11 +19,6 @@ return encodeURI(s).replace(/@/g, "%40"); } - function lws_urldecode(s) - { - return decodeURI(s).replace(/%40/g, "@"); - } - function trim(num) { var s = num.toString(); @@ -31,10 +26,10 @@ if (!s.indexOf(".")) return s; - while (s.length && s[s.length - 1] == "0") + while (s.length && s[s.length - 1] === "0") s = s.substring(0, s.length - 1); - if (s[s.length - 1] == ".") + if (s[s.length - 1] === ".") s = s.substring(0, s.length - 1); return s; @@ -90,7 +85,7 @@ var formData = new FormData(); var t = document.getElementById("ongoing"); - formData.append('file', file); + formData.append("file", file); var row = t.insertRow(0), c1 = row.insertCell(0), c2 = row.insertCell(1), c3 = row.insertCell(2); @@ -115,7 +110,7 @@ return; fetch("upload/" + lws_urlencode(file.name), { - method: 'POST', + method: "POST", body: formData }) .then((e) => { /* this just means we got a response code */ @@ -144,7 +139,7 @@ t.rows[n].cells[0] = "FAIL"; break; } - }) + }); } function da_drop(e) { @@ -155,7 +150,7 @@ clear_errors(); - ([...e.dataTransfer.files]).forEach(do_upload) + ([...e.dataTransfer.files]).forEach(do_upload); } function upl_button(e) { @@ -165,7 +160,7 @@ clear_errors(); e.preventDefault(); - ([...fi.files]).forEach(do_upload) + ([...fi.files]).forEach(do_upload); } function body_drop(e) { @@ -184,7 +179,7 @@ e.stopPropagation(); e.preventDefault(); - ws.send("{\"del\":\"" + lws_urldecode(e.target.getAttribute("file")) + + ws.send("{\"del\":\"" + decodeURI(e.target.getAttribute("file")) + "\"}"); } @@ -302,4 +297,4 @@ } }); -}()); \ No newline at end of file +}()); diff --git a/plugins/deaddrop/assets/deaddrop.js b/plugins/deaddrop/assets/deaddrop.js index 9bd3d7f7f..ebb6e12fa 100644 --- a/plugins/deaddrop/assets/deaddrop.js +++ b/plugins/deaddrop/assets/deaddrop.js @@ -26,10 +26,10 @@ if (!s.indexOf(".")) return s; - while (s.length && s[s.length - 1] == "0") + while (s.length && s[s.length - 1] === "0") s = s.substring(0, s.length - 1); - if (s[s.length - 1] == ".") + if (s[s.length - 1] === ".") s = s.substring(0, s.length - 1); return s; @@ -85,7 +85,7 @@ var formData = new FormData(); var t = document.getElementById("ongoing"); - formData.append('file', file); + formData.append("file", file); var row = t.insertRow(0), c1 = row.insertCell(0), c2 = row.insertCell(1), c3 = row.insertCell(2); @@ -110,7 +110,7 @@ return; fetch("upload/" + lws_urlencode(file.name), { - method: 'POST', + method: "POST", body: formData }) .then((e) => { /* this just means we got a response code */ @@ -139,7 +139,7 @@ t.rows[n].cells[0] = "FAIL"; break; } - }) + }); } function da_drop(e) { @@ -150,7 +150,7 @@ clear_errors(); - ([...e.dataTransfer.files]).forEach(do_upload) + ([...e.dataTransfer.files]).forEach(do_upload); } function upl_button(e) { @@ -160,7 +160,7 @@ clear_errors(); e.preventDefault(); - ([...fi.files]).forEach(do_upload) + ([...fi.files]).forEach(do_upload); } function body_drop(e) { @@ -297,4 +297,4 @@ } }); -}()); \ No newline at end of file +}());