From 579547c84966fdfb99883a2e9d85c2439ceca9cc Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Sun, 5 Jun 2022 20:05:23 +0200 Subject: [PATCH] smtp: minor line loop cleanup --- src/app-layer-smtp.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/app-layer-smtp.c b/src/app-layer-smtp.c index 92fc71e9a9..e83de0b62e 100644 --- a/src/app-layer-smtp.c +++ b/src/app-layer-smtp.c @@ -1329,7 +1329,6 @@ static AppLayerResult SMTPParse(uint8_t direction, Flow *f, SMTPState *state, AppLayerParserState *pstate, StreamSlice stream_slice, SMTPThreadCtx *thread_data) { SCEnter(); - SMTPLine line = { NULL, 0, 0 }; const uint8_t *input_buf = StreamSliceGetData(&stream_slice); uint32_t input_len = StreamSliceGetDataLen(&stream_slice); @@ -1344,7 +1343,9 @@ static AppLayerResult SMTPParse(uint8_t direction, Flow *f, SMTPState *state, } SMTPInput input = { .buf = input_buf, .len = input_len, .orig_len = input_len, .consumed = 0 }; + SMTPLine line = { NULL, 0, 0 }; + /* toserver */ if (direction == 0) { if (((state->current_command == SMTP_COMMAND_DATA) || (state->current_command == SMTP_COMMAND_BDAT)) && @@ -1354,11 +1355,7 @@ static AppLayerResult SMTPParse(uint8_t direction, Flow *f, SMTPState *state, SCReturnStruct(APP_LAYER_OK); } } - } - AppLayerResult res = SMTPGetLine(state, &input, &line); - - /* toserver */ - if (direction == 0) { + AppLayerResult res = SMTPGetLine(state, &input, &line); while (res.status == 0) { DEBUG_VALIDATE_BUG_ON(state->discard_till_lf); if (!state->discard_till_lf) { @@ -1378,6 +1375,7 @@ static AppLayerResult SMTPParse(uint8_t direction, Flow *f, SMTPState *state, return res; /* toclient */ } else { + AppLayerResult res = SMTPGetLine(state, &input, &line); while (res.status == 0) { DEBUG_VALIDATE_BUG_ON(state->discard_till_lf); if (!state->discard_till_lf) {