This is an automated email from the ASF dual-hosted git repository.

cliffjansen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git


The following commit(s) were added to refs/heads/main by this push:
     new 2e8c767a3 PROTON-2622: tls library - ensure capacity values match 
given capacity
2e8c767a3 is described below

commit 2e8c767a3bf2d2488a9edeac854243dcfe37068d
Author: Clifford Jansen <[email protected]>
AuthorDate: Wed Oct 26 12:17:58 2022 -0700

    PROTON-2622: tls library - ensure capacity values match given capacity
---
 c/src/tls/openssl.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/c/src/tls/openssl.c b/c/src/tls/openssl.c
index 4aadc8861..ab125cb82 100644
--- a/c/src/tls/openssl.c
+++ b/c/src/tls/openssl.c
@@ -442,8 +442,18 @@ size_t pn_tls_get_session_error_string(pn_tls_t* tls, char 
*buf, size_t buf_len)
   return strlen(buf);
 }
 
-size_t pn_tls_get_encrypt_input_buffer_capacity(pn_tls_t *tls) { return 
tls->encrypt_buffer_empty_count; }
-size_t pn_tls_get_decrypt_input_buffer_capacity(pn_tls_t *tls) { return 
tls->decrypt_buffer_empty_count; }
+size_t pn_tls_get_encrypt_input_buffer_capacity(pn_tls_t *tls) {
+  if (tls->enc_closed || tls->stopped || tls->pn_tls_err)
+    return 0;
+  return tls->encrypt_buffer_empty_count;
+}
+
+size_t pn_tls_get_decrypt_input_buffer_capacity(pn_tls_t *tls) {
+    if (tls->dec_closed || tls->stopped || tls->pn_tls_err)
+        return 0;
+    return tls->decrypt_buffer_empty_count;
+}
+
 size_t pn_tls_get_encrypt_output_buffer_capacity(pn_tls_t *tls) { return 
tls->eresult_empty_count; }
 size_t pn_tls_get_decrypt_output_buffer_capacity(pn_tls_t *tls) { return 
tls->dresult_empty_count; }
 
@@ -1566,8 +1576,6 @@ static void pbuffer_to_raw_buffer(pbuffer_t *pbuf, 
pn_raw_buffer_t *rbuf) {
 size_t pn_tls_give_encrypt_input_buffers(pn_tls_t* tls, pn_raw_buffer_t const* 
bufs, size_t count_bufs) {
   assert(tls);
 
-  if (tls->enc_closed || tls->stopped || tls->pn_tls_err)
-    return 0;
   size_t can_take = pn_min(count_bufs, 
pn_tls_get_encrypt_input_buffer_capacity(tls));
   if ( can_take==0 ) return 0;
 
@@ -1602,8 +1610,6 @@ size_t pn_tls_give_encrypt_input_buffers(pn_tls_t* tls, 
pn_raw_buffer_t const* b
 size_t pn_tls_give_decrypt_input_buffers(pn_tls_t* tls, pn_raw_buffer_t const* 
bufs, size_t count_bufs) {
   assert(tls);
 
-  if (tls->dec_closed || tls->stopped || tls->pn_tls_err)
-    return 0;
   size_t can_take = pn_min(count_bufs, 
pn_tls_get_decrypt_input_buffer_capacity(tls));
   if ( can_take==0 ) return 0;
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to