From: Vsevolod Stakhov Date: Sat, 7 May 2016 11:21:15 +0000 (+0100) Subject: [Fix] Adjust body/body_buf when stealing encrypted message X-Git-Tag: 1.3.0~528 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2eb9f5304f4f0b06798214f2840f57c9bd908843;p=thirdparty%2Frspamd.git [Fix] Adjust body/body_buf when stealing encrypted message --- diff --git a/src/libutil/http.c b/src/libutil/http.c index d15c7d99ba..fef9cb73cc 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) {