From: Eric Leblond Date: Tue, 5 May 2015 13:00:58 +0000 (+0200) Subject: smtp: add 'body-md5' mime option X-Git-Tag: suricata-3.0RC1~125 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=990055842830a65cb31ea51c52a06412c3d6c191;p=thirdparty%2Fsuricata.git smtp: add 'body-md5' mime option This option will allow the user to select weither or not he wants to journalize the md5 of the mail body. --- diff --git a/src/app-layer-smtp.c b/src/app-layer-smtp.c index ed034d4ed6..139533468f 100644 --- a/src/app-layer-smtp.c +++ b/src/app-layer-smtp.c @@ -220,7 +220,7 @@ SCEnumCharMap smtp_reply_map[ ] = { }; /* Create SMTP config structure */ -SMTPConfig smtp_config = { 0, { 0, 0, 0, 0 }, 0, 0, 0}; +SMTPConfig smtp_config = { 0, { 0, 0, 0, 0, 0 }, 0, 0, 0}; static SMTPString *SMTPStringAlloc(void); @@ -266,6 +266,11 @@ static void SMTPConfigure(void) { if (ret) { smtp_config.mime_config.extract_urls = val; } + + ret = ConfGetChildValueBool(config, "body-md5", &val); + if (ret) { + smtp_config.mime_config.body_md5 = val; + } } /* Pass mime config data to MimeDec API */ diff --git a/src/util-decode-mime.c b/src/util-decode-mime.c index 3b33c548de..312a9af493 100644 --- a/src/util-decode-mime.c +++ b/src/util-decode-mime.c @@ -79,7 +79,7 @@ #define MAX_IP6_CHARS 39 /* Globally hold configuration data */ -static MimeDecConfig mime_dec_config = { 1, 1, 1, MAX_HEADER_VALUE }; +static MimeDecConfig mime_dec_config = { 1, 1, 1, 0, MAX_HEADER_VALUE }; #ifdef DEBUG /* Mime Parser String translation */ @@ -2182,7 +2182,7 @@ static int ProcessMimeBody(const uint8_t *buf, uint32_t len, uint32_t tlen; #ifdef HAVE_NSS - if (state->body_begin == 1 && (state->md5_ctx == NULL)) { + if (MimeDecGetConfig()->body_md5 && state->body_begin == 1 && (state->md5_ctx == NULL)) { state->md5_ctx = HASH_Create(HASH_AlgMD5); if (state->md5_ctx != NULL) { HASH_Begin(state->md5_ctx); diff --git a/src/util-decode-mime.h b/src/util-decode-mime.h index 69f328e3c6..020a1f1665 100644 --- a/src/util-decode-mime.h +++ b/src/util-decode-mime.h @@ -97,6 +97,7 @@ typedef struct MimeDecConfig { int decode_base64; /**< Decode base64 bodies */ int decode_quoted_printable; /**< Decode quoted-printable bodies */ int extract_urls; /**< Extract and store URLs in data structure */ + int body_md5; /**< Compute md5 sum of body */ uint32_t header_value_depth; /**< Depth of which to store header values (Default is 2000) */ } MimeDecConfig;