comparison src/mail/ngx_mail_parse.c @ 7837:ba8a8299b904

Mail: optimized discarding invalid SMTP commands. There is no need to scan buffer from s->buffer->pos, as we already scanned the buffer till "p" and wasn't able to find an LF. There is no real need for this change in SMTP, since it is at most a microoptimization of a non-common code path. Similar code in IMAP, however, will have to start scanning from "p" to be correct, since there can be newlines in IMAP literals.
author Maxim Dounin <mdounin@mdounin.ru>
date Wed, 19 May 2021 03:13:17 +0300
parents 6a81d96d3733
children 815c63581be4
comparison
equal deleted inserted replaced
7836:6a81d96d3733 7837:ba8a8299b904
841 s->state = sw_invalid; 841 s->state = sw_invalid;
842 s->arg_start = NULL; 842 s->arg_start = NULL;
843 843
844 /* skip invalid command till LF */ 844 /* skip invalid command till LF */
845 845
846 for (p = s->buffer->pos; p < s->buffer->last; p++) { 846 for ( /* void */ ; p < s->buffer->last; p++) {
847 if (*p == LF) { 847 if (*p == LF) {
848 s->state = sw_start; 848 s->state = sw_start;
849 s->buffer->pos = p + 1; 849 s->buffer->pos = p + 1;
850 return NGX_MAIL_PARSE_INVALID_COMMAND; 850 return NGX_MAIL_PARSE_INVALID_COMMAND;
851 } 851 }