diff --git a/lib/roles/cgi/cgi-server.c b/lib/roles/cgi/cgi-server.c index c09416226..f9f954717 100644 --- a/lib/roles/cgi/cgi-server.c +++ b/lib/roles/cgi/cgi-server.c @@ -167,7 +167,7 @@ lws_cgi(struct lws *wsi, const char * const *exec_array, if (m >= 0) { env_array[n++] = p; - if (m < 8) { + if (m < (int)LWS_ARRAY_SIZE(meths) - 1) { p += lws_snprintf(p, end - p, "REQUEST_METHOD=%s", meth_names[m]); diff --git a/lib/roles/mqtt/mqtt.c b/lib/roles/mqtt/mqtt.c index bb07feb53..8e2079de1 100644 --- a/lib/roles/mqtt/mqtt.c +++ b/lib/roles/mqtt/mqtt.c @@ -1760,7 +1760,10 @@ lws_mqtt_client_send_subcribe(struct lws *wsi, lws_mqtt_subscribe_param_t *sub) lws_mqtt_str_t mqtt_vh_payload; uint8_t exists[8], extant; lws_mqtt_subs_t *mysub; - uint32_t rem_len, tops; + uint32_t rem_len; +#if defined(_DEBUG) + uint32_t tops; +#endif uint32_t n; assert(sub->num_topics); @@ -1826,6 +1829,7 @@ lws_mqtt_client_send_subcribe(struct lws *wsi, lws_mqtt_subscribe_param_t *sub) return 0; } +#if defined(_DEBUG) /* * zero or more of the topics already existed, but not all, * so we must go to the server with a filtered list of the @@ -1833,6 +1837,7 @@ lws_mqtt_client_send_subcribe(struct lws *wsi, lws_mqtt_subscribe_param_t *sub) */ tops = sub->num_topics - extant; +#endif /* * Pid + (Topic len field + Topic len + Req. QoS) x Num of Topics @@ -1844,8 +1849,10 @@ lws_mqtt_client_send_subcribe(struct lws *wsi, lws_mqtt_subscribe_param_t *sub) wsi->mqtt->sub_size = rem_len; +#if defined(_DEBUG) lwsl_debug("%s: Number of topics = %d, Remaining len = %d\n", __func__, (int)tops, (int)rem_len); +#endif p += lws_mqtt_vbi_encode(rem_len, p); @@ -1933,8 +1940,11 @@ lws_mqtt_client_send_unsubcribe(struct lws *wsi, struct lws *nwsi = lws_get_network_wsi(wsi); lws_mqtt_str_t mqtt_vh_payload; uint8_t send_unsub[8], orphaned; - uint32_t rem_len, n, tops; + uint32_t rem_len, n; lws_mqtt_subs_t *mysub; +#if defined(_DEBUG) + uint32_t tops; +#endif lwsl_info("%s: Enter\n", __func__); @@ -1978,7 +1988,7 @@ lws_mqtt_client_send_unsubcribe(struct lws *wsi, return 0; } - +#if defined(_DEBUG) /* * one or more of the topics needs to be unsubscribed * from, so we must go to the server with a filtered @@ -1986,6 +1996,7 @@ lws_mqtt_client_send_unsubcribe(struct lws *wsi, */ tops = orphaned; +#endif if (lws_mqtt_fill_fixed_header(p++, LMQCP_CTOS_UNSUBSCRIBE, 0, 0, 0)) { diff --git a/lib/roles/raw-skt/ops-raw-skt.c b/lib/roles/raw-skt/ops-raw-skt.c index 75d1776fb..9cdfe2f98 100644 --- a/lib/roles/raw-skt/ops-raw-skt.c +++ b/lib/roles/raw-skt/ops-raw-skt.c @@ -32,7 +32,7 @@ rops_handle_POLLIN_raw_skt(struct lws_context_per_thread *pt, struct lws *wsi, const char *cce = NULL; #endif struct lws_tokens ebuf; - int n, buffered; + int n = 0, buffered = 0; /* pending truncated sends have uber priority */ diff --git a/lib/tls/openssl/openssl-client.c b/lib/tls/openssl/openssl-client.c index cbf95f509..7d435806c 100644 --- a/lib/tls/openssl/openssl-client.c +++ b/lib/tls/openssl/openssl-client.c @@ -369,13 +369,17 @@ lws_tls_client_connect(struct lws *wsi) char a[32]; unsigned int len; #endif - int m, n, en; + int m, n; +#if defined(WIN32) || defined(_DEBUG) + int en; +#endif errno = 0; ERR_clear_error(); n = SSL_connect(wsi->tls.ssl); +#if defined(WIN32) || defined(_DEBUG) en = errno; - +#endif m = lws_ssl_get_error(wsi, n); if (m == SSL_ERROR_SYSCALL @@ -383,7 +387,9 @@ lws_tls_client_connect(struct lws *wsi) && en #endif ) { +#if defined(WIN32) || defined(_DEBUG) lwsl_info("%s: n %d, m %d, errno %d\n", __func__, n, m, en); +#endif return LWS_SSL_CAPABLE_ERROR; } diff --git a/minimal-examples/secure-streams/minimal-secure-streams-avs/avs.c b/minimal-examples/secure-streams/minimal-secure-streams-avs/avs.c index 722b4a01f..fe8dd2eea 100644 --- a/minimal-examples/secure-streams/minimal-secure-streams-avs/avs.c +++ b/minimal-examples/secure-streams/minimal-secure-streams-avs/avs.c @@ -124,7 +124,11 @@ ss_avs_metadata_rx(void *userobj, const uint8_t *buf, size_t len, int flags) lwsl_info("%s: len %d, buf h %d, t %d, space %d\n", __func__, (int)len, (int)m->head, (int)m->tail, (int)n); lws_ss_get_est_peer_tx_credit(m->ss); - assert (len <= n); + if (len > n) { + assert(0); + lwsl_err("%s: bad len\n", __func__); + return 1; + } if (m->head < m->tail) /* |****h-------t**| */ memcpy(&m->buf[m->head], buf, len);