diff src/mail/ngx_mail_pop3_handler.c @ 9235:d7fd0acdea64

Mail: handling of pipelined commands which cross buffer boundary. Previously, pipelined commands which cross buffer boundary were rejected as too long, even if the command itself was short enough to be handled within the client buffer. Fix is to move non-processed commands to the start of the buffer after the previous command is fully processed.
author Maxim Dounin <mdounin@mdounin.ru>
date Sat, 30 Mar 2024 05:05:31 +0300
parents c690a902bfec
children 32d4582c484d
line wrap: on
line diff
--- a/src/mail/ngx_mail_pop3_handler.c
+++ b/src/mail/ngx_mail_pop3_handler.c
@@ -119,6 +119,7 @@ ngx_mail_pop3_init_protocol(ngx_event_t 
 void
 ngx_mail_pop3_auth_state(ngx_event_t *rev)
 {
+    size_t               n;
     ngx_int_t            rc;
     ngx_connection_t    *c;
     ngx_mail_session_t  *s;
@@ -291,6 +292,12 @@ ngx_mail_pop3_auth_state(ngx_event_t *re
         if (s->buffer->pos == s->buffer->last) {
             s->buffer->pos = s->buffer->start;
             s->buffer->last = s->buffer->start;
+
+        } else {
+            n = s->buffer->last - s->buffer->pos;
+            ngx_memmove(s->buffer->start, s->buffer->pos, n);
+            s->buffer->pos = s->buffer->start;
+            s->buffer->last = s->buffer->start + n;
         }
 
         if (s->state) {