output-json: avoid freeing caller-owned JSON builder

EveEmailLogJsonData() freed the provided SCJsonBuilder when
SMTP state was unavailable, even though ownership remains with
the caller. The caller may continue using the builder for
cleanup after the function returns failure.

Return failure without freeing the builder and add defensive
NULL checks in EveSmtpDataLogger().

Signed-off-by: Urval Kheni <urvalkheni777@gmail.com>
pull/15601/head
Urval 3 months ago committed by Victor Julien
parent 0345b91ddd
commit 3b9dc5ad37

@ -148,8 +148,7 @@ static bool EveEmailLogJsonData(
smtp_state = (SMTPState *)state;
if (smtp_state == NULL) {
SCLogDebug("no smtp state, so no request logging");
SCJbFree(sjs);
SCReturnPtr(NULL, "SCJsonBuilder");
SCReturnBool(false);
}
SMTPTransaction *tx = vtx;
mime_state = tx->mime_state;

@ -53,6 +53,10 @@
static void EveSmtpDataLogger(void *state, void *vtx, SCJsonBuilder *js)
{
if (state == NULL || vtx == NULL) {
return;
}
SMTPTransaction *tx = vtx;
SMTPString *rcptto_str;
if (((SMTPState *)state)->helo) {

Loading…
Cancel
Save