From be97ac1b817f1edb4a447fe97bc6099ff5f473fb Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Sun, 12 Jun 2022 17:23:47 +0200 Subject: [PATCH] pop3: don't ignore last character in a line when looking for newline Fixes: gromox-0.19-99-g89441188a (loop boundary not updated) Fixes: gromox-1.24-92-gb6df52a4a (loop boundary one short) --- mra/pop3/pop3_parser.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mra/pop3/pop3_parser.cpp b/mra/pop3/pop3_parser.cpp index 3617f3537..14a3179e4 100644 --- a/mra/pop3/pop3_parser.cpp +++ b/mra/pop3/pop3_parser.cpp @@ -207,7 +207,7 @@ int pop3_parser_process(POP3_CONTEXT *pcontext) const char *host_ID; char temp_command[1024]; char reply_buf[1024]; - size_t ub, string_length = 0; + size_t string_length = 0; if (pcontext->is_stls) { if (NULL == pcontext->connection.ssl) { @@ -386,10 +386,8 @@ int pop3_parser_process(POP3_CONTEXT *pcontext) pcontext->connection.last_timestamp = current_time; pcontext->read_offset += read_len; - /* Microoptimization (cf. imap_parser for the same) */ - ub = pcontext->read_offset > 0 ? pcontext->read_offset - 1 : 0; - for (size_t i = 0; i < ub; ++i) { - auto nl_len = newline_size(&pcontext->read_buffer[i], ub - i); + for (size_t i = 0; i < pcontext->read_offset; ++i) { + auto nl_len = newline_size(&pcontext->read_buffer[i], pcontext->read_offset - i); if (nl_len == 0) continue; memcpy(temp_command, pcontext->read_buffer, i);