From 22ffdbb1b32222fd9be7efb9efe96fce653d5904 Mon Sep 17 00:00:00 2001 From: Philippe Antoine Date: Mon, 4 Sep 2023 15:51:16 +0200 Subject: [PATCH] mime: process chunk as soon as possible In the case stream depth gets reached afterwards, it cannot be processed after that. Ticket: #6367 --- src/util-decode-mime.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/util-decode-mime.c b/src/util-decode-mime.c index b22a8c2e6f..8e8b426c44 100644 --- a/src/util-decode-mime.c +++ b/src/util-decode-mime.c @@ -1375,17 +1375,22 @@ static int ProcessBase64BodyLine(const uint8_t *buf, uint32_t len, * size. We strip of spaces this while storing it in bvremain */ if (consumed_bytes == 0 && leftover_bytes > B64_BLOCK) { DEBUG_VALIDATE_BUG_ON(state->bvr_len != 0); - return ProcessBase64BodyLineCopyRemainder(buf, len, offset, state); + ret = ProcessBase64BodyLineCopyRemainder(buf, len, offset, state); + break; } else if (leftover_bytes > 0 && leftover_bytes <= B64_BLOCK) { /* If remaining is 4 by this time, we encountered spaces during processing */ DEBUG_VALIDATE_BUG_ON(state->bvr_len != 0); - return ProcessBase64BodyLineCopyRemainder(buf, len, offset + consumed_bytes, state); + ret = ProcessBase64BodyLineCopyRemainder(buf, len, offset + consumed_bytes, state); + break; } /* Update counts */ remaining = leftover_bytes; offset += consumed_bytes; } + if (ret == MIME_DEC_OK && state->data_chunk_len > 0) { + ret = ProcessDecodedDataChunk(state->data_chunk, state->data_chunk_len, state); + } return ret; } -- 2.47.2