From 9c3c6cf4cc8fb28e920023bbeb263293c8f03566 Mon Sep 17 00:00:00 2001 From: Alice Akaki Date: Mon, 24 Mar 2025 17:08:31 -0400 Subject: [PATCH] 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") --- src/detect-email.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) 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); -- 2.47.2