From 5f6c38f77e9f1e5ba930661fc0400958f6817b38 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 19 Oct 2015 19:02:59 +0100 Subject: [PATCH] Fix parsing of the last header in encrypted HTTP messages --- src/libutil/http.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/libutil/http.c b/src/libutil/http.c index 5b3c7d9be..1afa9ac18 100644 --- a/src/libutil/http.c +++ b/src/libutil/http.c @@ -670,6 +670,32 @@ rspamd_http_on_body_decrypted (http_parser * parser, const gchar *at, size_t len return 0; } +static int +rspamd_http_on_headers_complete_decrypted (http_parser *parser) +{ + struct rspamd_http_connection *conn = + (struct rspamd_http_connection *) parser->data; + struct rspamd_http_connection_private *priv; + + priv = conn->priv; + + if (priv->header != NULL) { + rspamd_http_finish_header (conn, priv); + + priv->header = NULL; + priv->new_header = FALSE; + } + + if (parser->flags & F_SPAMC) { + priv->msg->flags |= RSPAMD_HTTP_FLAG_SPAMC; + } + + priv->msg->method = parser->method; + priv->msg->code = parser->status_code; + + return 0; +} + static int rspamd_http_decrypt_message (struct rspamd_http_connection *conn, struct rspamd_http_connection_private *priv, @@ -724,6 +750,7 @@ rspamd_http_decrypt_message (struct rspamd_http_connection *conn, decrypted_cb.on_status = rspamd_http_on_status; decrypted_cb.on_header_field = rspamd_http_on_header_field; decrypted_cb.on_header_value = rspamd_http_on_header_value; + decrypted_cb.on_headers_complete = rspamd_http_on_headers_complete_decrypted; decrypted_cb.on_body = rspamd_http_on_body_decrypted; decrypted_parser.data = conn; decrypted_parser.content_length = dec_len; -- 2.39.5