From 2eb9f5304f4f0b06798214f2840f57c9bd908843 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 7 May 2016 12:21:15 +0100 Subject: [PATCH] [Fix] Adjust body/body_buf when stealing encrypted message --- src/libutil/http.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/libutil/http.c b/src/libutil/http.c index d15c7d99b..fef9cb73c 100644 --- a/src/libutil/http.c +++ b/src/libutil/http.c @@ -1172,6 +1172,13 @@ rspamd_http_connection_steal_msg (struct rspamd_http_connection *conn) msg->peer_key = NULL; } priv->msg = NULL; + + /* We also might need to adjust body/body_buf */ + if (msg->body_buf.begin > msg->body->str) { + memmove (msg->body->str, msg->body_buf.begin, msg->body_buf.len); + msg->body->len = msg->body_buf.len; + msg->body_buf.begin = msg->body->str; + } } return msg; @@ -1192,6 +1199,8 @@ rspamd_http_connection_copy_msg (struct rspamd_http_connection *conn) if (msg->body) { new_msg->body = rspamd_fstring_new_init (msg->body->str, msg->body->len); + new_msg->body_buf.begin = msg->body_buf.begin; + new_msg->body_buf.len = msg->body_buf.len; } if (msg->url) { -- 2.39.5