]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix sending of large entries via HTTPS
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 14 Aug 2019 08:55:41 +0000 (09:55 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 14 Aug 2019 08:55:41 +0000 (09:55 +0100)
src/libutil/http_connection.c

index 094438ee6e7de5894300c83771ac25b7e0c1793a..31e8a3c1e29029f72aafa27114a285452b11f47f 100644 (file)
@@ -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;