[nginx] Mail: removed dead s->arg_start handling.

Maxim Dounin mdounin at mdounin.ru
Wed May 19 01:27:23 UTC 2021


details:   https://hg.nginx.org/nginx/rev/379d461eccf4
branches:  
changeset: 7840:379d461eccf4
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Wed May 19 03:13:22 2021 +0300
description:
Mail: removed dead s->arg_start handling.

As discussed in the previous change, s->arg_start handling in the "done"
labels of ngx_mail_pop3_parse_command(), ngx_mail_imap_parse_command(),
and ngx_mail_smtp_parse_command() is wrong: s->arg_start cannot be
set there, as it is handled and cleared on all code paths where the
"done" labels are reached.  The relevant code is dead and now removed.

diffstat:

 src/mail/ngx_mail.h       |   1 -
 src/mail/ngx_mail_parse.c |  47 -----------------------------------------------
 2 files changed, 0 insertions(+), 48 deletions(-)

diffs (130 lines):

diff -r 3974f4e56a4e -r 379d461eccf4 src/mail/ngx_mail.h
--- a/src/mail/ngx_mail.h	Wed May 19 03:13:20 2021 +0300
+++ b/src/mail/ngx_mail.h	Wed May 19 03:13:22 2021 +0300
@@ -238,7 +238,6 @@ typedef struct {
     ngx_uint_t              state;
     u_char                 *cmd_start;
     u_char                 *arg_start;
-    u_char                 *arg_end;
     ngx_uint_t              literal_len;
 } ngx_mail_session_t;
 
diff -r 3974f4e56a4e -r 379d461eccf4 src/mail/ngx_mail_parse.c
--- a/src/mail/ngx_mail_parse.c	Wed May 19 03:13:20 2021 +0300
+++ b/src/mail/ngx_mail_parse.c	Wed May 19 03:13:22 2021 +0300
@@ -124,10 +124,8 @@ ngx_mail_pop3_parse_command(ngx_mail_ses
                 break;
             case CR:
                 state = sw_almost_done;
-                s->arg_end = p;
                 break;
             case LF:
-                s->arg_end = p;
                 goto done;
             default:
                 if (s->args.nelts <= 2) {
@@ -202,17 +200,6 @@ ngx_mail_pop3_parse_command(ngx_mail_ses
 done:
 
     s->buffer->pos = p + 1;
-
-    if (s->arg_start) {
-        arg = ngx_array_push(&s->args);
-        if (arg == NULL) {
-            return NGX_ERROR;
-        }
-        arg->len = s->arg_end - s->arg_start;
-        arg->data = s->arg_start;
-        s->arg_start = NULL;
-    }
-
     s->state = (s->command != NGX_POP3_AUTH) ? sw_start : sw_argument;
 
     return NGX_OK;
@@ -220,7 +207,6 @@ done:
 invalid:
 
     s->state = sw_invalid;
-    s->arg_start = NULL;
 
     /* skip invalid command till LF */
 
@@ -436,10 +422,8 @@ ngx_mail_imap_parse_command(ngx_mail_ses
                 break;
             case CR:
                 state = sw_almost_done;
-                s->arg_end = p;
                 break;
             case LF:
-                s->arg_end = p;
                 goto done;
             case '"':
                 if (s->args.nelts <= 2) {
@@ -614,22 +598,6 @@ ngx_mail_imap_parse_command(ngx_mail_ses
 done:
 
     s->buffer->pos = p + 1;
-
-    if (s->arg_start) {
-        arg = ngx_array_push(&s->args);
-        if (arg == NULL) {
-            return NGX_ERROR;
-        }
-        arg->len = s->arg_end - s->arg_start;
-        arg->data = s->arg_start;
-
-        s->arg_start = NULL;
-        s->cmd_start = NULL;
-        s->quoted = 0;
-        s->no_sync_literal = 0;
-        s->literal_len = 0;
-    }
-
     s->state = (s->command != NGX_IMAP_AUTHENTICATE) ? sw_start : sw_argument;
 
     return NGX_OK;
@@ -637,7 +605,6 @@ done:
 invalid:
 
     s->state = sw_start;
-    s->arg_start = NULL;
     s->quoted = 0;
     s->backslash = 0;
     s->no_sync_literal = 0;
@@ -786,10 +753,8 @@ ngx_mail_smtp_parse_command(ngx_mail_ses
                 break;
             case CR:
                 state = sw_almost_done;
-                s->arg_end = p;
                 break;
             case LF:
-                s->arg_end = p;
                 goto done;
             default:
                 if (s->args.nelts <= 10) {
@@ -849,17 +814,6 @@ ngx_mail_smtp_parse_command(ngx_mail_ses
 done:
 
     s->buffer->pos = p + 1;
-
-    if (s->arg_start) {
-        arg = ngx_array_push(&s->args);
-        if (arg == NULL) {
-            return NGX_ERROR;
-        }
-        arg->len = s->arg_end - s->arg_start;
-        arg->data = s->arg_start;
-        s->arg_start = NULL;
-    }
-
     s->state = (s->command != NGX_SMTP_AUTH) ? sw_start : sw_argument;
 
     return NGX_OK;
@@ -867,7 +821,6 @@ done:
 invalid:
 
     s->state = sw_invalid;
-    s->arg_start = NULL;
 
     /* skip invalid command till LF */
 


More information about the nginx-devel mailing list