]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
smtp: minor line loop cleanup 7488/head
authorVictor Julien <vjulien@oisf.net>
Sun, 5 Jun 2022 18:05:23 +0000 (20:05 +0200)
committerVictor Julien <vjulien@oisf.net>
Mon, 6 Jun 2022 07:02:43 +0000 (09:02 +0200)
src/app-layer-smtp.c

index 92fc71e9a92acd35b9ad790718e71807f3b87f1f..e83de0b62e04c021d7ad32111e5170fe23ad0c76 100644 (file)
@@ -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) {