diff options
author | Florin Coras <fcoras@cisco.com> | 2019-11-11 13:58:34 -0800 |
---|---|---|
committer | Dave Wallace <dwallacelf@gmail.com> | 2019-11-12 17:21:51 +0000 |
commit | 55a9dacbb81e17d81b61449cbc11ac1f9249b801 (patch) | |
tree | 85338765d8d61a5eebf701a28a051b686f5f6c39 /src/plugins | |
parent | a03c7d5b9280e1cd5d89cb7cc15bd05b56062c95 (diff) |
tls: fix picotls coverity warnings
Type: fix
Change-Id: Ib5c9de9c9053b8339f514ff648a75c3b56b55215
Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/tlspicotls/tls_picotls.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/plugins/tlspicotls/tls_picotls.c b/src/plugins/tlspicotls/tls_picotls.c index aa8203f22dc..7f1979422fe 100644 --- a/src/plugins/tlspicotls/tls_picotls.c +++ b/src/plugins/tlspicotls/tls_picotls.c @@ -127,7 +127,7 @@ picotls_start_listen (tls_ctx_t * lctx) }; ckpair = app_cert_key_pair_get_if_valid (lctx->ckpair_index); - if (!ckpair->cert || !ckpair->key) + if (!ckpair || !ckpair->cert || !ckpair->key) { TLS_DBG (1, "tls cert and/or key not configured %d", ctx->parent_app_wrk_index); @@ -218,7 +218,7 @@ picotls_do_handshake (picotls_ctx_t * ptls_ctx, session_t * tls_session, ptls_t *tls = ptls_ctx->tls; ptls_buffer_t buf; int rv = PTLS_ERROR_IN_PROGRESS; - int write, off; + int write = 0, off; do { @@ -231,8 +231,8 @@ picotls_do_handshake (picotls_ctx_t * ptls_ctx, session_t * tls_session, off += consumed; if ((rv == 0 || rv == PTLS_ERROR_IN_PROGRESS) && buf.off != 0) { - write = - picotls_try_handshake_write (ptls_ctx, tls_session, &buf); + write = picotls_try_handshake_write (ptls_ctx, tls_session, + &buf); } ptls_buffer_dispose (&buf); } @@ -260,32 +260,32 @@ picotls_ctx_read (tls_ctx_t * ctx, session_t * tls_session) if (!picotls_handshake_is_over (ctx)) { deq_max = svm_fifo_max_dequeue_cons (tls_rx_fifo); - input = malloc (deq_max); + input = clib_mem_alloc (deq_max); memset (input, 0, deq_max); deq_now = clib_min (deq_max, svm_fifo_max_read_chunk (tls_rx_fifo)); if (!deq_now) - return 0; + goto done_hs; from_tls_len += svm_fifo_dequeue (tls_rx_fifo, deq_now, input); if (from_tls_len <= 0) { tls_add_vpp_q_builtin_rx_evt (tls_session); - return 0; + goto done_hs; } if (from_tls_len < deq_max) { - deq_now = - clib_min (svm_fifo_max_read_chunk (tls_rx_fifo), - deq_max - from_tls_len); - from_tls_len += - svm_fifo_dequeue (tls_rx_fifo, deq_now, input + from_tls_len); + deq_now = clib_min (svm_fifo_max_read_chunk (tls_rx_fifo), + deq_max - from_tls_len); + from_tls_len += svm_fifo_dequeue (tls_rx_fifo, deq_now, + input + from_tls_len); } picotls_do_handshake (ptls_ctx, tls_session, input, from_tls_len); if (picotls_handshake_is_over (ctx)) tls_notify_app_accept (ctx); - free (input); + done_hs: + clib_mem_free (input); return 0; } |