From: Victor Julien Date: Sun, 5 Jun 2022 18:05:23 +0000 (+0200) Subject: smtp: minor line loop cleanup X-Git-Tag: suricata-7.0.0-beta1~497 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F7488%2Fhead;p=thirdparty%2Fsuricata.git smtp: minor line loop cleanup --- 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) {