Skip to content

Commit

Permalink
imap: do not emit continuation request on LITERAL+ (>64K literals)
Browse files Browse the repository at this point in the history
There are two code paths in imap; one for small literals that
fit within the command buffer, and one for APPEND-only large literals.
One case was missed…

See-also: gromox-2.13-30-g3c29de8a8
Fixes: gromox-2.10-138-g588cee298
References: GXL-120, GXL-268, GXF-1192, GXF-1240
  • Loading branch information
jengelh committed Oct 5, 2023
1 parent 9687376 commit 2cc3688
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
9 changes: 9 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
Development 2.14.3
==================

Fixes:

* imap: do not emit continuation request on LITERAL+
(now also for large literals >64K)


Gromox 2.14 (2023-10-04)
========================

Expand Down
1 change: 1 addition & 0 deletions mra/imap/imap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ struct imap_context final : public schedule_context {
STREAM stream; /* stream for writing to imap client */
int auth_times = 0;
char username[UADDR_SIZE]{}, maildir[256]{}, lang[32]{};
bool synchronizing_literal = true;
};
using IMAP_CONTEXT = imap_context;

Expand Down
14 changes: 8 additions & 6 deletions mra/imap/imap_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,9 @@ static tproc_status ps_literal_processing(imap_context *pcontext)
ctx.literal_ptr = &endbr[1]; /* skip over brace */
char *end = nullptr;
pcontext->literal_len = strtoul(&openbr[1], &end, 10);
bool synchronizing_literal = true;
pcontext->synchronizing_literal = true;
if (*end == '+' || (*end == '-' && pcontext->literal_len <= 4096)) {
synchronizing_literal = false;
pcontext->synchronizing_literal = false;
++end;
}
if (end != endbr) {
Expand Down Expand Up @@ -520,10 +520,10 @@ static tproc_status ps_literal_processing(imap_context *pcontext)

/* IMAP_CODE_2160003: + ready for additional command text */
size_t string_length = 0;
if (synchronizing_literal) {
auto imap_reply_str = resource_get_imap_code(1603, 1, &string_length);
pcontext->connection.write(imap_reply_str, string_length);
}
if (!pcontext->synchronizing_literal)
return tproc_status::literal_checking;
auto imap_reply_str = resource_get_imap_code(1603, 1, &string_length);
pcontext->connection.write(imap_reply_str, string_length);
return tproc_status::literal_checking;
}
memcpy(&ctx.command_buffer[ctx.command_len],
Expand Down Expand Up @@ -552,6 +552,8 @@ static tproc_status ps_literal_processing(imap_context *pcontext)
pcontext->sched_stat = isched_stat::appending;
pcontext->read_offset = 0;
pcontext->command_len = 0;
if (!pcontext->synchronizing_literal)
return tproc_status::cont;
/* IMAP_CODE_2160003 + Ready for additional command text */
size_t string_length = 0;
auto imap_reply_str = resource_get_imap_code(1603, 1, &string_length);
Expand Down

0 comments on commit 2cc3688

Please sign in to comment.