aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil/ssl_util.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-10-18 15:17:42 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-10-18 15:17:42 +0100
commit6fd9dcb0d8419b07460a174c6bd7baf78f6f3ebe (patch)
tree37027efcd366604c5e57c780bde462dd92d1c174 /src/libutil/ssl_util.c
parentf59abfc9be6018ceab2ea59a819ac22b8802eeac (diff)
downloadrspamd-6fd9dcb0d8419b07460a174c6bd7baf78f6f3ebe.tar.gz
rspamd-6fd9dcb0d8419b07460a174c6bd7baf78f6f3ebe.zip
[Fix] Fix handling of HTTP HEAD methods
Diffstat (limited to 'src/libutil/ssl_util.c')
-rw-r--r--src/libutil/ssl_util.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/libutil/ssl_util.c b/src/libutil/ssl_util.c
index 55d5a1ad4..c320dfd29 100644
--- a/src/libutil/ssl_util.c
+++ b/src/libutil/ssl_util.c
@@ -520,6 +520,11 @@ rspamd_ssl_read (struct rspamd_ssl_connection *conn, gpointer buf,
if (conn->state != ssl_conn_connected && conn->state != ssl_next_read) {
errno = EINVAL;
+ g_set_error (&err, rspamd_ssl_quark (), ECONNRESET,
+ "ssl state error: cannot read data");
+ conn->err_handler (conn->handler_data, err);
+ g_error_free (err);
+
return -1;
}
@@ -549,12 +554,13 @@ rspamd_ssl_read (struct rspamd_ssl_connection *conn, gpointer buf,
else {
ret = SSL_get_error (conn->ssl, ret);
conn->state = ssl_next_read;
+ what = 0;
if (ret == SSL_ERROR_WANT_READ) {
- what = EV_READ;
+ what |= EV_READ;
}
else if (ret == SSL_ERROR_WANT_WRITE) {
- what = EV_WRITE;
+ what |= EV_WRITE;
}
else {
g_set_error (&err, rspamd_ssl_quark (), ret,
@@ -603,8 +609,14 @@ rspamd_ssl_write (struct rspamd_ssl_connection *conn, gconstpointer buf,
ret = SSL_get_error (conn->ssl, ret);
if (ret == SSL_ERROR_ZERO_RETURN) {
+ g_set_error (&err, rspamd_ssl_quark (), ret,
+ "ssl write error: %s", ERR_error_string (ret, NULL));
+ conn->err_handler (conn->handler_data, err);
+ g_error_free (err);
+ errno = ECONNRESET;
conn->state = ssl_conn_reset;
- return 0;
+
+ return -1;
}
else {
g_set_error (&err, rspamd_ssl_quark (), ret,