Skip to content

Commit

Permalink
pop3: don't ignore last character in a line when looking for newline
Browse files Browse the repository at this point in the history
Fixes: gromox-0.19-99-g89441188a (loop boundary not updated)
Fixes: gromox-1.24-92-gb6df52a4a (loop boundary one short)
  • Loading branch information
jengelh committed Jun 12, 2022
1 parent 12a2dac commit be97ac1
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions mra/pop3/pop3_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit be97ac1

Please sign in to comment.