Skip to content

Commit

Permalink
[Fix] Fix sending of large entries via HTTPS
Browse files Browse the repository at this point in the history
  • Loading branch information
vstakhov committed Aug 14, 2019
1 parent 6be8ca5 commit 5a5e892
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/libutil/http_connection.c
Expand Up @@ -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 */
Expand All @@ -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);
Expand All @@ -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;
Expand Down

0 comments on commit 5a5e892

Please sign in to comment.