diff src/imap/ngx_imap_handler.c @ 286:5bef04fc3fd5 NGINX_0_5_13

nginx 0.5.13 *) Feature: the COPY and MOVE methods. *) Bugfix: the ngx_http_realip_module set garbage for requests passed via keep-alive connection. *) Bugfix: nginx did not work on big-endian 64-bit Linux. Thanks to Andrei Nigmatulin. *) Bugfix: now when IMAP/POP3 proxy receives too long command it closes the connection right away, but not after timeout. *) Bugfix: if the "epoll" method was used and a client closed a connection prematurely, then nginx closed the connection after a send timeout only. *) Bugfix: nginx could not be built on platforms different from i386, amd64, sparc and ppc; bug appeared in 0.5.8.
author Igor Sysoev <http://sysoev.ru>
date Mon, 19 Feb 2007 00:00:00 +0300
parents 052a7b1d40e5
children
line wrap: on
line diff
--- a/src/imap/ngx_imap_handler.c
+++ b/src/imap/ngx_imap_handler.c
@@ -802,7 +802,9 @@ ngx_pop3_auth_state(ngx_event_t *rev)
 
                 if (arg[0].len == 5) {
 
-                    if (ngx_strncasecmp(arg[0].data, "LOGIN", 5) == 0) {
+                    if (ngx_strncasecmp(arg[0].data, (u_char *) "LOGIN", 5)
+                        == 0)
+                    {
 
                         if (s->args.nelts != 1) {
                             rc = NGX_IMAP_PARSE_INVALID_COMMAND;
@@ -816,7 +818,10 @@ ngx_pop3_auth_state(ngx_event_t *rev)
 
                         break;
 
-                    } else if (ngx_strncasecmp(arg[0].data, "PLAIN", 5) == 0) {
+                    } else if (ngx_strncasecmp(arg[0].data, (u_char *) "PLAIN",
+                                               5)
+                               == 0)
+                    {
 
                         if (s->args.nelts == 1) {
                             s->imap_state = ngx_pop3_auth_plain;
@@ -856,7 +861,9 @@ ngx_pop3_auth_state(ngx_event_t *rev)
                     }
 
                 } else if (arg[0].len == 8
-                           && ngx_strncasecmp(arg[0].data, "CRAM-MD5", 8) == 0)
+                           && ngx_strncasecmp(arg[0].data,
+                                              (u_char *) "CRAM-MD5", 8)
+                              == 0)
                 {
                     s->imap_state = ngx_pop3_auth_cram_md5;
 
@@ -1205,6 +1212,7 @@ ngx_imap_read_command(ngx_imap_session_t
 {
     ssize_t    n;
     ngx_int_t  rc;
+    ngx_str_t  l;
 
     n = s->connection->recv(s->connection, s->buffer->last,
                             s->buffer->end - s->buffer->last);
@@ -1233,10 +1241,24 @@ ngx_imap_read_command(ngx_imap_session_t
         rc = ngx_imap_parse_command(s);
     }
 
-    if (rc == NGX_AGAIN
-        || rc == NGX_IMAP_NEXT
-        || rc == NGX_IMAP_PARSE_INVALID_COMMAND)
-    {
+    if (rc == NGX_AGAIN) {
+
+        if (s->buffer->last < s->buffer->end) {
+            return rc;
+        }
+
+        l.len = s->buffer->last - s->buffer->start;
+        l.data = s->buffer->start;
+
+        ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
+                      "client sent too long command \"%V\"", &l);
+
+        s->quit = 1;
+
+        return NGX_IMAP_PARSE_INVALID_COMMAND;
+    }
+
+    if (rc == NGX_IMAP_NEXT || rc == NGX_IMAP_PARSE_INVALID_COMMAND) {
         return rc;
     }