]> git.ipfire.org Git - thirdparty/suricata.git/commit
smtp: fix indefinite buffering if no LF in line
authorShivani Bhardwaj <shivanib134@gmail.com>
Mon, 14 Feb 2022 11:23:52 +0000 (16:53 +0530)
committerShivani Bhardwaj <shivanib134@gmail.com>
Thu, 21 Apr 2022 07:31:56 +0000 (13:01 +0530)
commit7f5115395fd918417e4914ab42143f2ee91e6e28
tree6781e3cf9827a0aa6f7220694db44fb1194b3b89
parent7d30fb152afdbbea81dfa601f239254da2b786e9
smtp: fix indefinite buffering if no LF in line

Issue
-----
So far, with the SMTP parser, we would buffer data up until an LF char
was found indicating the end of one line. This would happen in case of
fragmented data where a line might come broken into multiple chunks.
This was problematic if there was a really long line without any LF
character. It would mean that we'd keep buffering data up until we
encounter one such LF char which may be many many bytes of data later.

Fix
---
Fix this issue by setting an upper limit of 4KB on the buffering of
lines. If the limit is reached then we save the data into current line
and process it as if it were a regular request/response up until 4KB
only. Any data after 4KB is discarded up until there is a new LF char in
the received input.

Cases
-----
1. Fragmentation
The limit is enforced for any cases where a line of >= 4KB comes as diff
fragments that are each/some < 4KB.
2. Single too long line
The limit is also enforced for any cases where a single line exceeds the
limit of buffer.

Reported by Victor Julien.
Ticket 5023

(cherry picked from commit 078c251deacc78b8abb40c5ab89d19c29e31bdf8)
src/app-layer-smtp.c
src/app-layer-smtp.h