Skip to content

Commit

Permalink
Mail: removed dead s->arg_start handling.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mdounin committed May 19, 2021
1 parent 3c660ef commit fabe282
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 48 deletions.
1 change: 0 additions & 1 deletion src/mail/ngx_mail.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
47 changes: 0 additions & 47 deletions src/mail/ngx_mail_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,8 @@ ngx_mail_pop3_parse_command(ngx_mail_session_t *s)
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) {
Expand Down Expand Up @@ -202,25 +200,13 @@ ngx_mail_pop3_parse_command(ngx_mail_session_t *s)
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;

invalid:

s->state = sw_invalid;
s->arg_start = NULL;

/* skip invalid command till LF */

Expand Down Expand Up @@ -436,10 +422,8 @@ ngx_mail_imap_parse_command(ngx_mail_session_t *s)
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) {
Expand Down Expand Up @@ -614,30 +598,13 @@ ngx_mail_imap_parse_command(ngx_mail_session_t *s)
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;

invalid:

s->state = sw_start;
s->arg_start = NULL;
s->quoted = 0;
s->backslash = 0;
s->no_sync_literal = 0;
Expand Down Expand Up @@ -786,10 +753,8 @@ ngx_mail_smtp_parse_command(ngx_mail_session_t *s)
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) {
Expand Down Expand Up @@ -849,25 +814,13 @@ ngx_mail_smtp_parse_command(ngx_mail_session_t *s)
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;

invalid:

s->state = sw_invalid;
s->arg_start = NULL;

/* skip invalid command till LF */

Expand Down

0 comments on commit fabe282

Please sign in to comment.