commit 5a5e892: [Fix] Fix sending of large entries via HTTPS

Vsevolod Stakhov vsevolod at highsecure.ru
Wed Aug 14 09:00:06 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-08-14 09:55:41 +0100
URL: https://github.com/rspamd/rspamd/commit/5a5e892a64a1d23964010620c529d0947d692237

[Fix] Fix sending of large entries via HTTPS

---
 src/libutil/http_connection.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/libutil/http_connection.c b/src/libutil/http_connection.c
index 094438ee6..31e8a3c1e 100644
--- a/src/libutil/http_connection.c
+++ b/src/libutil/http_connection.c
@@ -774,7 +774,13 @@ rspamd_http_write_helper (struct rspamd_http_connection *conn)
 	niov = priv->outlen;
 	remain = priv->wr_pos;
 	/* We know that niov is small enough for that */
-	cur_iov = alloca (niov * sizeof (struct iovec));
+	if (priv->ssl) {
+		/* Might be recursive! */
+		cur_iov = g_malloc (niov * sizeof (struct iovec));
+	}
+	else {
+		cur_iov = alloca (niov * sizeof (struct iovec));
+	}
 	memcpy (cur_iov, priv->out, niov * sizeof (struct iovec));
 	for (i = 0; i < priv->outlen && remain > 0; i++) {
 		/* Find out the first iov required */
@@ -801,6 +807,7 @@ rspamd_http_write_helper (struct rspamd_http_connection *conn)
 
 	if (priv->ssl) {
 		r = rspamd_ssl_writev (priv->ssl, msg.msg_iov, msg.msg_iovlen);
+		g_free (cur_iov);
 	}
 	else {
 		r = sendmsg (conn->fd, &msg, flags);
@@ -827,6 +834,12 @@ rspamd_http_write_helper (struct rspamd_http_connection *conn)
 	else {
 		/* Want to write more */
 		priv->flags &= ~RSPAMD_HTTP_CONN_FLAG_RESETED;
+
+		if (priv->ssl && r > 0) {
+			/* We can write more data... */
+			rspamd_http_write_helper (conn);
+			return;
+		}
 	}
 
 	return;


More information about the Commits mailing list