From: Victor Julien Date: Fri, 15 Apr 2022 13:49:09 +0000 (+0200) Subject: mime: allow partial lines as input X-Git-Tag: suricata-5.0.9~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6eb49cd3651017c0f7b0609cba2108d298347f86;p=thirdparty%2Fsuricata.git mime: allow partial lines as input If we get a zero length delim we assume its a partial line and we won't append CRLF just yet. (cherry picked from commit 6e800a8548d9d2699589cac6afca3c0fa7613202) --- diff --git a/src/util-decode-mime.c b/src/util-decode-mime.c index a9afb7623e..3b1cc4ab5c 100644 --- a/src/util-decode-mime.c +++ b/src/util-decode-mime.c @@ -1448,8 +1448,8 @@ static int ProcessQuotedPrintableBodyLine(const uint8_t *buf, uint32_t len, state->data_chunk_len++; entity->decoded_body_len += 1; - /* Add CRLF sequence if end of line */ - if (remaining == 1) { + /* Add CRLF sequence if end of line, unless its a partial line */ + if (remaining == 1 && state->current_line_delimiter_len > 0) { memcpy(state->data_chunk + state->data_chunk_len, CRLF, EOL_LEN); state->data_chunk_len += EOL_LEN; entity->decoded_body_len += EOL_LEN; @@ -1486,8 +1486,8 @@ static int ProcessQuotedPrintableBodyLine(const uint8_t *buf, uint32_t len, state->data_chunk_len++; entity->decoded_body_len++; - /* Add CRLF sequence if end of line */ - if (remaining == 3) { + /* Add CRLF sequence if end of line, unless for partial lines */ + if (remaining == 3 && state->current_line_delimiter_len > 0) { memcpy(state->data_chunk + state->data_chunk_len, CRLF, EOL_LEN); state->data_chunk_len += EOL_LEN; @@ -1576,8 +1576,8 @@ static int ProcessBodyLine(const uint8_t *buf, uint32_t len, memcpy(state->data_chunk + state->data_chunk_len, buf + offset, tobuf); state->data_chunk_len += tobuf; - /* Now always add a CRLF to the end */ - if (tobuf == remaining) { + /* Now always add a CRLF to the end, unless its a partial line */ + if (tobuf == remaining && state->current_line_delimiter_len > 0) { memcpy(state->data_chunk + state->data_chunk_len, CRLF, EOL_LEN); state->data_chunk_len += EOL_LEN; }