From: Alice Akaki Date: Mon, 24 Mar 2025 21:08:31 +0000 (-0400) Subject: detect-email.c: don't return NULL for empty buffer X-Git-Tag: suricata-8.0.0-beta1~230 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c3c6cf4cc8fb28e920023bbeb263293c8f03566;p=thirdparty%2Fsuricata.git detect-email.c: don't return NULL for empty buffer Just return NULL if tx->mime_state is NULL or if SCDetectMimeEmailGetData return 0 Fixes: 09db7c7 ("detect: add mime email.subject keyword") 90aab0d ("detect: add email.from") --- diff --git a/src/detect-email.c b/src/detect-email.c index 74b151142c..a88122e92d 100644 --- a/src/detect-email.c +++ b/src/detect-email.c @@ -48,13 +48,10 @@ static InspectionBuffer *GetMimeEmailFromData(DetectEngineThreadCtx *det_ctx, const uint8_t *b_email_from = NULL; uint32_t b_email_from_len = 0; - if ((tx->mime_state != NULL)) { - if (SCDetectMimeEmailGetData( - tx->mime_state, &b_email_from, &b_email_from_len, "from") != 1) - return NULL; - } + if (tx->mime_state == NULL) + return NULL; - if (b_email_from == NULL || b_email_from_len == 0) + if (SCDetectMimeEmailGetData(tx->mime_state, &b_email_from, &b_email_from_len, "from") != 1) return NULL; InspectionBufferSetup(det_ctx, list_id, buffer, b_email_from, b_email_from_len); @@ -85,13 +82,11 @@ static InspectionBuffer *GetMimeEmailSubjectData(DetectEngineThreadCtx *det_ctx, const uint8_t *b_email_sub = NULL; uint32_t b_email_sub_len = 0; - if ((tx->mime_state != NULL)) { - if (SCDetectMimeEmailGetData( - tx->mime_state, &b_email_sub, &b_email_sub_len, "subject") != 1) - return NULL; - } + if (tx->mime_state == NULL) + return NULL; - if (b_email_sub == NULL || b_email_sub_len == 0) + if (SCDetectMimeEmailGetData(tx->mime_state, &b_email_sub, &b_email_sub_len, "subject") != + 1) return NULL; InspectionBufferSetup(det_ctx, list_id, buffer, b_email_sub, b_email_sub_len);