Skip to content

Commit

Permalink
smtp: fix null deref with config option body md5
Browse files Browse the repository at this point in the history
Ticket: #6279

If we have the smtp body beginning without headers, we need to
create the md5 context and right away and supply data to it.
Otherwise, on the next line being processed, md5_ctx will be
NULL but body_begin will have been reset to 0
  • Loading branch information
catenacyber authored and victorjulien committed Sep 13, 2023
1 parent 00e0025 commit c6afee6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/util-decode-mime.c
Original file line number Diff line number Diff line change
Expand Up @@ -1766,6 +1766,12 @@ static int FindMimeHeader(const uint8_t *buf, uint32_t blen,
state->body_begin = 1;
state->body_end = 0;

// Begin the body md5 computation if config asks so
if (MimeDecGetConfig()->body_md5 && state->md5_ctx == NULL) {
state->md5_ctx = SCMd5New();
SCMd5Update(state->md5_ctx, buf, blen + state->current_line_delimiter_len);
}

ret = ProcessBodyLine(buf, blen, state);
if (ret != MIME_DEC_OK) {
SCLogDebug("Error: ProcessBodyLine() function failed");
Expand Down

0 comments on commit c6afee6

Please sign in to comment.