Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1725 v2 #1952

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/output-json-email-common.c
Expand Up @@ -119,6 +119,9 @@ static json_t* JsonEmailJsonArrayFromCommaList(const uint8_t *val, size_t len)
sp = SkipWhiteSpaceTill(p, savep);
json_array_append_new(ajs, json_string(sp));
}
} else {
json_decref(ajs);
return NULL;
}
SCFree(to_line);
}
Expand Down Expand Up @@ -250,6 +253,7 @@ json_t *JsonEmailLogJsonData(const Flow *f, void *state, void *vtx, uint64_t tx_
smtp_state = (SMTPState *)state;
if (smtp_state == NULL) {
SCLogDebug("no smtp state, so no request logging");
json_decref(sjs);
SCReturnPtr(NULL, "json_t");
}
SMTPTransaction *tx = vtx;
Expand All @@ -259,10 +263,12 @@ json_t *JsonEmailLogJsonData(const Flow *f, void *state, void *vtx, uint64_t tx_
break;
default:
/* don't know how we got here */
json_decref(sjs);
SCReturnPtr(NULL, "json_t");
}
if ((mime_state != NULL)) {
if (entity == NULL) {
json_decref(sjs);
SCReturnPtr(NULL, "json_t");
}

Expand Down Expand Up @@ -302,8 +308,10 @@ json_t *JsonEmailLogJsonData(const Flow *f, void *state, void *vtx, uint64_t tx_
}
}

if (mime_state->stack == NULL || mime_state->stack->top == NULL || mime_state->stack->top->data == NULL)
if (mime_state->stack == NULL || mime_state->stack->top == NULL || mime_state->stack->top->data == NULL) {
json_decref(sjs);
SCReturnPtr(NULL, "json_t");
}

entity = (MimeDecEntity *)mime_state->stack->top->data;
int attch_cnt = 0;
Expand Down Expand Up @@ -371,6 +379,10 @@ TmEcode JsonEmailLogJson(JsonEmailLogThread *aft, json_t *js, const Packet *p, F
OutputJsonEmailCtx *email_ctx = aft->emaillog_ctx;
SMTPTransaction *tx = (SMTPTransaction *) vtx;

if (sjs == NULL) {
SCReturnInt(TM_ECODE_FAILED);
}

if ((email_ctx->flags & LOG_EMAIL_EXTENDED) || (email_ctx->fields != 0))
JsonEmailLogJSONCustom(email_ctx, sjs, tx);

Expand Down