[PATCH 6 of 7] Mail: add 'Not Enough Arguments' imap error message

Filipe da Silva fdasilvayy at gmail.com
Tue Jan 14 11:54:23 UTC 2014


# HG changeset patch
# User Filipe da Silva <fdasilvayy at gmail.com>
# Date 1389700279 -3600
#      Tue Jan 14 12:51:19 2014 +0100
# Node ID 4c742929908a54e06516e80493a42846b9b35420
# Parent  147c57844b913f2b1a4dafb44d58e1128039ea03
Mail: add 'Not Enough Arguments' imap error message.
It allow to notify some functionnal errors, instead of the generic 'Invalid Error' message

diff -r 147c57844b91 -r 4c742929908a src/mail/ngx_mail.h
--- a/src/mail/ngx_mail.h	Tue Jan 14 12:51:12 2014 +0100
+++ b/src/mail/ngx_mail.h	Tue Jan 14 12:51:19 2014 +0100
@@ -320,6 +320,7 @@
 
 #define NGX_MAIL_PARSE_INVALID_COMMAND  20
 
+#define NGX_MAIL_PARSE_NOT_ENOUGH_ARGUMENTS  21
 
 typedef void (*ngx_mail_init_session_pt)(ngx_mail_session_t *s,
     ngx_connection_t *c);
diff -r 147c57844b91 -r 4c742929908a src/mail/ngx_mail_imap_handler.c
--- a/src/mail/ngx_mail_imap_handler.c	Tue Jan 14 12:51:12 2014 +0100
+++ b/src/mail/ngx_mail_imap_handler.c	Tue Jan 14 12:51:19 2014 +0100
@@ -33,6 +33,7 @@
 static u_char  imap_password[] = "+ UGFzc3dvcmQ6" CRLF;
 static u_char  imap_bye[] = "* BYE" CRLF;
 static u_char  imap_invalid_command[] = "BAD invalid command" CRLF;
+static u_char  imap_not_enough_arguments[] = "BAD not enough arguments" CRLF;
 
 static ngx_str_t  ngx_mail_imap_client_id_nil = ngx_string("ID NIL");
 static ngx_str_t  ngx_mail_imap_server_id_nil = ngx_string("* ID NIL" CRLF);
@@ -253,6 +254,12 @@
         ngx_str_set(&s->out, imap_invalid_command);
         s->mail_state = ngx_imap_start;
         break;
+
+    case NGX_MAIL_PARSE_NOT_ENOUGH_ARGUMENTS:
+        s->state = 0;
+        ngx_str_set(&s->out, imap_not_enough_arguments);
+        s->mail_state = ngx_imap_start;
+        break;
     }
 
     if (tag) {
@@ -311,14 +318,14 @@
 
     arg = s->args.elts;
     if (s->args.nelts < 1 || arg[0].len == 0) {
-        return NGX_MAIL_PARSE_INVALID_COMMAND;
+        return NGX_MAIL_PARSE_NOT_ENOUGH_ARGUMENTS;
     }
 
     // Client sends ID NIL or ID ( ... )
     if (s->args.nelts == 1) {
 
         if (ngx_strncasecmp(arg[0].data, (u_char *) "NIL", 3) != 0)
-            return NGX_MAIL_PARSE_INVALID_COMMAND;
+            return NGX_MAIL_PARSE_NOT_ENOUGH_ARGUMENTS;
 
         s->imap_client_id = ngx_mail_imap_client_id_nil;
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 005-ImapTooFewArguments.diff
Type: text/x-patch
Size: 2251 bytes
Desc: not available
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20140114/1761c7bb/attachment.bin>


More information about the nginx-devel mailing list