aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-11-05 12:08:17 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-11-05 12:08:17 +0000
commita2af525bbd71f141eafadb78fa8ac8e76788bee6 (patch)
tree47bf9fcea2582cad3dcfd05c53d260c941b34ece
parent1ee4b159437edc1d991860008371f587c3283cda (diff)
downloadrspamd-a2af525bbd71f141eafadb78fa8ac8e76788bee6.tar.gz
rspamd-a2af525bbd71f141eafadb78fa8ac8e76788bee6.zip
[Fix] Check results of write message as SSL can bork them
-rw-r--r--src/client/rspamdclient.c11
-rw-r--r--src/libutil/http_connection.c22
-rw-r--r--src/libutil/http_connection.h4
-rw-r--r--src/lua/lua_http.c4
4 files changed, 21 insertions, 20 deletions
diff --git a/src/client/rspamdclient.c b/src/client/rspamdclient.c
index b8e89fcd7..e80926087 100644
--- a/src/client/rspamdclient.c
+++ b/src/client/rspamdclient.c
@@ -324,6 +324,7 @@ rspamd_client_command (struct rspamd_client_connection *conn,
gsize dict_len = 0;
void *dict = NULL;
ZSTD_CCtx *zctx;
+ gboolean ret;
req = g_malloc0 (sizeof (struct rspamd_client_request));
req->conn = conn;
@@ -457,16 +458,16 @@ rspamd_client_command (struct rspamd_client_connection *conn,
conn->start_time = rspamd_get_ticks (FALSE);
if (compressed) {
- rspamd_http_connection_write_message (conn->http_conn, req->msg, NULL,
- "application/x-compressed", req,
+ ret = rspamd_http_connection_write_message (conn->http_conn, req->msg,
+ NULL,"application/x-compressed", req,
conn->timeout);
}
else {
- rspamd_http_connection_write_message (conn->http_conn, req->msg, NULL,
- "text/plain", req, conn->timeout);
+ ret = rspamd_http_connection_write_message (conn->http_conn, req->msg,
+ NULL,"text/plain", req, conn->timeout);
}
- return TRUE;
+ return ret;
}
void
diff --git a/src/libutil/http_connection.c b/src/libutil/http_connection.c
index f7da1ee83..ca87c205a 100644
--- a/src/libutil/http_connection.c
+++ b/src/libutil/http_connection.c
@@ -1195,7 +1195,7 @@ rspamd_http_connection_new_client (struct rspamd_http_context *ctx,
if (fd == -1) {
msg_info ("cannot connect to http proxy %s: %s",
- rspamd_inet_address_to_string (proxy_addr),
+ rspamd_inet_address_to_string_pretty (proxy_addr),
strerror (errno));
rspamd_upstream_fail (up, TRUE);
@@ -1214,8 +1214,8 @@ rspamd_http_connection_new_client (struct rspamd_http_context *ctx,
fd = rspamd_inet_address_connect (addr, SOCK_STREAM, TRUE);
if (fd == -1) {
- msg_info ("cannot connect to proxy %s: %s",
- rspamd_inet_address_to_string (addr),
+ msg_info ("cannot connect make http connection to %s: %s",
+ rspamd_inet_address_to_string_pretty (addr),
strerror (errno));
return NULL;
@@ -1905,7 +1905,7 @@ rspamd_http_message_write_header (const gchar* mime_type, gboolean encrypted,
return meth_len;
}
-static void
+static gboolean
rspamd_http_connection_write_message_common (struct rspamd_http_connection *conn,
struct rspamd_http_message *msg,
const gchar *host,
@@ -2236,7 +2236,7 @@ rspamd_http_connection_write_message_common (struct rspamd_http_connection *conn
conn->error_handler (conn, err);
rspamd_http_connection_unref (conn);
g_error_free (err);
- return;
+ return FALSE;
}
else {
if (priv->ssl) {
@@ -2261,7 +2261,7 @@ rspamd_http_connection_write_message_common (struct rspamd_http_connection *conn
conn->error_handler (conn, err);
rspamd_http_connection_unref (conn);
g_error_free (err);
- return;
+ return FALSE;
}
}
}
@@ -2270,9 +2270,11 @@ rspamd_http_connection_write_message_common (struct rspamd_http_connection *conn
rspamd_http_event_handler, conn);
rspamd_ev_watcher_start (priv->ctx->event_loop, &priv->ev, priv->timeout);
}
+
+ return TRUE;
}
-void
+gboolean
rspamd_http_connection_write_message (struct rspamd_http_connection *conn,
struct rspamd_http_message *msg,
const gchar *host,
@@ -2280,11 +2282,11 @@ rspamd_http_connection_write_message (struct rspamd_http_connection *conn,
gpointer ud,
ev_tstamp timeout)
{
- rspamd_http_connection_write_message_common (conn, msg, host, mime_type,
+ return rspamd_http_connection_write_message_common (conn, msg, host, mime_type,
ud, timeout, FALSE);
}
-void
+gboolean
rspamd_http_connection_write_message_shared (struct rspamd_http_connection *conn,
struct rspamd_http_message *msg,
const gchar *host,
@@ -2292,7 +2294,7 @@ rspamd_http_connection_write_message_shared (struct rspamd_http_connection *conn
gpointer ud,
ev_tstamp timeout)
{
- rspamd_http_connection_write_message_common (conn, msg, host, mime_type,
+ return rspamd_http_connection_write_message_common (conn, msg, host, mime_type,
ud, timeout, TRUE);
}
diff --git a/src/libutil/http_connection.h b/src/libutil/http_connection.h
index b90d0125a..7c901fd2a 100644
--- a/src/libutil/http_connection.h
+++ b/src/libutil/http_connection.h
@@ -240,7 +240,7 @@ void rspamd_http_connection_read_message_shared (
* @param ud opaque user data
* @param fd fd to read/write
*/
-void rspamd_http_connection_write_message (
+gboolean rspamd_http_connection_write_message (
struct rspamd_http_connection *conn,
struct rspamd_http_message *msg,
const gchar *host,
@@ -248,7 +248,7 @@ void rspamd_http_connection_write_message (
gpointer ud,
ev_tstamp timeout);
-void rspamd_http_connection_write_message_shared (
+gboolean rspamd_http_connection_write_message_shared (
struct rspamd_http_connection *conn,
struct rspamd_http_message *msg,
const gchar *host,
diff --git a/src/lua/lua_http.c b/src/lua/lua_http.c
index 6f541b962..f7dd01e87 100644
--- a/src/lua/lua_http.c
+++ b/src/lua/lua_http.c
@@ -455,11 +455,9 @@ lua_http_make_connection (struct lua_http_cbdata *cbd)
/* Message is now owned by a connection object */
cbd->msg = NULL;
- rspamd_http_connection_write_message (cbd->conn, msg,
+ return rspamd_http_connection_write_message (cbd->conn, msg,
cbd->host, cbd->mime_type, cbd,
cbd->timeout);
-
- return TRUE;
}
return FALSE;