Module: kamailio
Branch: 5.7
Commit: 2e6e879adc949b52cd2824fa233db901e5d045bc
URL:
https://github.com/kamailio/kamailio/commit/2e6e879adc949b52cd2824fa233db90…
Author: S-P Chan <shihping.chan(a)gmail.com>
Committer: S-P Chan <shihping.chan(a)gmail.com>
Date: 2024-01-27T07:19:11+08:00
tls_wolfssl: fix ring buffer write
(cherry-pick from 04ca08d0da622519578c479664a85563ec6db483)
---
Modified: src/modules/tls_wolfssl/tls_server.c
---
Diff:
https://github.com/kamailio/kamailio/commit/2e6e879adc949b52cd2824fa233db90…
Patch:
https://github.com/kamailio/kamailio/commit/2e6e879adc949b52cd2824fa233db90…
---
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: