From 1b9e4fba061e3549d3db7ed6ae00d0a81d29b570 Mon Sep 17 00:00:00 2001 From: Shivani Bhardwaj Date: Tue, 6 Jun 2023 16:18:12 +0530 Subject: [PATCH] ftp: don't decrement truncated line len In case LF was found for a long line way outside of the limit, we should not need to update the delimiter len and current line len because the line is capped at 4k and the LF was not within these 4k bytes. --- src/app-layer-ftp.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/app-layer-ftp.c b/src/app-layer-ftp.c index 33b46a906f..fee52a3e61 100644 --- a/src/app-layer-ftp.c +++ b/src/app-layer-ftp.c @@ -471,12 +471,13 @@ static int FTPGetLineForDirection( state->current_line_len = lf_idx - state->input; } - if (state->input != lf_idx && - *(lf_idx - 1) == 0x0D) { - state->current_line_len--; - state->current_line_delimiter_len = 2; - } else { - state->current_line_delimiter_len = 1; + if (!*current_line_truncated) { + if (state->input != lf_idx && *(lf_idx - 1) == 0x0D) { + state->current_line_len--; + state->current_line_delimiter_len = 2; + } else { + state->current_line_delimiter_len = 1; + } } } -- 2.47.2