Module: kamailio
Branch: master
Commit: 04ca08d0da622519578c479664a85563ec6db483
URL: 
https://github.com/kamailio/kamailio/commit/04ca08d0da622519578c479664a85563ec6db483

Author: S-P Chan <[email protected]>
Committer: S-P Chan <[email protected]>
Date: 2024-01-27T07:09:19+08:00

tls_wolfssl: fix ring buffer write

---

Modified: src/modules/tls_wolfssl/tls_server.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/04ca08d0da622519578c479664a85563ec6db483.diff
Patch: 
https://github.com/kamailio/kamailio/commit/04ca08d0da622519578c479664a85563ec6db483.patch

---

diff --git a/src/modules/tls_wolfssl/tls_server.c 
b/src/modules/tls_wolfssl/tls_server.c
index 730b7524475..8b5006c4780 100644
--- a/src/modules/tls_wolfssl/tls_server.c
+++ b/src/modules/tls_wolfssl/tls_server.c
@@ -637,6 +637,7 @@ void tls_h_tcpconn_clean_f(struct tcp_connection *c)
  * wolfSSL implementation detail: BIO pair uses a ring buffer -
  * wolfSSL_BIO_read does not do wrap-around; you may need a 2-pass read
  * 1st read - front of buffer, 2nd read - wrap-around
+ * fixed in 4f1d777090 post-v5.6.6-stable
  */
 
 void tls_h_tcpconn_close_f(struct tcp_connection *c, int fd)
@@ -1040,7 +1041,16 @@ int tls_h_read_f(struct tcp_connection *c, 
rd_conn_flags_t *flags)
                                goto error;
                }
                rd_pending = bytes_read;
-               nw = wolfSSL_BIO_write(rwbio, rd_buf, rd_pending);
+               /*
+                * use 2-pass write for wolfSSL ring buffer
+                * fixed in 4f1d777090, post-v5.6.6-stable
+                */
+               for(nw = 0; nw < rd_pending; ) {
+                       npos = wolfSSL_BIO_write(rwbio, rd_buf+nw, 
rd_pending-nw);
+                       if(npos<=0)
+                               break;
+                       nw += npos;
+               }
                assert(nw==rd_pending);
        }
  continue_ssl_read:

_______________________________________________
Kamailio (SER) - Development Mailing List
To unsubscribe send an email to [email protected]

Reply via email to