]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Check results of write message as SSL can bork them
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 5 Nov 2019 12:08:17 +0000 (12:08 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 5 Nov 2019 12:08:17 +0000 (12:08 +0000)
src/client/rspamdclient.c
src/libutil/http_connection.c
src/libutil/http_connection.h
src/lua/lua_http.c

index b8e89fcd7c7ef2d114617936ba0ef49b217da87b..e80926087d21492de38be41e80c8a6c894f96444 100644 (file)
@@ -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
index f7da1ee836aa34768e4338a62890bd17b690c6ee..ca87c205ab8240fa5fffd2f89b6b1a7ef71c8d1e 100644 (file)
@@ -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);
 }
 
index b90d0125ad8fe41a22cbfd191e027ae4396627ef..7c901fd2a0f287f0ddd8e233c6d823193af34e99 100644 (file)
@@ -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,
index 6f541b96207b56c6b04068e49a9eceff40b636d8..f7dd01e878198ffe566060cdf947d6f20208ebf2 100644 (file)
@@ -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;