smtp-reply-parser.c revision bcb4e51a409d94ae670de96afb8483a4f7855294
766N/A/* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */ 180N/A Reply-line = *( Reply-code "-" [ textstring ] CRLF ) 0N/A Reply-code [ SP textstring ] CRLF 737N/A Reply-code = %x32-35 %x30-35 %x30-39 737N/A textstring = 1*(%d09 / %d32-126) ; HT, SP, Printable US-ASCII 737N/A Greeting = ( "220 " (Domain / address-literal) 737N/A [ SP textstring ] CRLF ) / 769N/A ( "220-" (Domain / address-literal) 748N/A *( "220-" [ textstring ] CRLF ) 749N/A "220" [ SP textstring ] CRLF ) 751N/A ehlo-ok-rsp = ( "250" SP Domain [ SP ehlo-greet ] CRLF ) 751N/A / ( "250-" Domain [ SP ehlo-greet ] CRLF 751N/A *( "250-" ehlo-line CRLF ) 759N/A "250" SP ehlo-line CRLF ) 765N/A ehlo-greet = 1*(%d0-9 / %d11-12 / %d14-127) 767N/A ; string of any characters other than CR or LF 768N/A ehlo-line = ehlo-keyword *( SP ehlo-param ) 737N/A ehlo-keyword = (ALPHA / DIGIT) *(ALPHA / DIGIT / "-") 737N/A ; additional syntax of ehlo-params depends on 713N/A ehlo-param = 1*(%d33-126) 713N/A ; any CHAR excluding <SP> and all 713N/A ; control characters (US-ASCII 0-31 and 127 718N/A status-code ::= class "." subject "." detail 719N/A class ::= "2" / "4" / "5" 488N/A const unsigned char *p;
534N/A /* Reply-code = %x32-35 %x30-35 %x30-39 443N/A if (p[0] <
'2' || p[0] >
'5' || p[
1] >
'5')
482N/A *
code_r = (p[0] -
'0')*
100 + (p[
1] -
'0')*
10 + (p[
2] -
'0');
336N/A /* textstring = 1*(%d09 / %d32-126) ; HT, SP, Printable US-ASCII 389N/A "Reply exceeds size limit");
316N/A "Reply exceeds size limit");
247N/A /* ehlo-greet = 1*(%d0-9 / %d11-12 / %d14-127) 252N/A * The greet is not supposed to be empty, but we don't really care 135N/A "Reply exceeds size limit");
179N/A /* sanitize bad characters */ 189N/A if (c >=
0x20 && c <
0x7F)
40N/A return;
/* failed on earlier line */ 101N/A /* status-code ::= class "." subject "." detail 104N/A class ::= "2" / "4" / "5" 22N/A if (p[
1] !=
'.' || (p[0] !=
'2' && p[0] !=
'4' && p[0] !=
'5'))
62N/A y = y*
10 + (*p -
'0');
3N/A z = z*
10 + (*p -
'0');
0N/A if (
digits == 0 || (*p !=
' ' && *p !=
'\r' && *p !=
'\n'))
0N/A /* code is syntactically valid; strip code from textstring */ 0N/A /* check for match with status */ 0N/A /* check for code consistency */ 0N/A Reply-line = *( Reply-code "-" [ textstring ] CRLF ) 0N/A Reply-code [ SP textstring ] CRLF 0N/A Reply-code = %x32-35 %x30-35 %x30-39 0N/A ehlo-ok-rsp = ( "250" SP Domain [ SP ehlo-greet ] CRLF ) 0N/A / ( "250-" Domain [ SP ehlo-greet ] CRLF 0N/A *( "250-" ehlo-line CRLF ) 0N/A "250" SP ehlo-line CRLF ) 0N/A "Invalid status code in reply");
0N/A "Inconsistent status codes in reply");
0N/A /* "-" / SP / CRLF */ 0N/A /* "-" [ textstring ] CRLF */ 0N/A /* SP [ textstring ] CRLF ; allow missing text */ 0N/A "Encountered unexpected %s after reply status code",
0N/A /* textstring / (Domain [ SP ehlo-greet ]) */ 0N/A /* handle first line of EHLO success response 0N/A differently because it can contain control 0N/A characters (WHY??!) */ 0N/A "Encountered stray CR in reply text");
0N/A "Encountered stray %s in reply text",
0N/A "Premature end of input");
0N/A Reply-line = *( Reply-code "-" [ textstring ] CRLF ) 0N/A Reply-code [ SP textstring ] CRLF 0N/A Reply-code = %x32-35 %x30-35 %x30-39 0N/A textstring = 1*(%d09 / %d32-126) ; HT, SP, Printable US-ASCII 0N/A Greeting is not handled specially here. 0N/A ehlo-ok-rsp = ( "250" SP Domain [ SP ehlo-greet ] CRLF ) 0N/A / ( "250-" Domain [ SP ehlo-greet ] CRLF 0N/A *( "250-" ehlo-line CRLF ) 0N/A "250" SP ehlo-line CRLF ) 0N/A ehlo-greet = 1*(%d0-9 / %d11-12 / %d14-127) 0N/A ; string of any characters other than CR or LF 0N/A ehlo-line = ehlo-keyword *( SP ehlo-param ) 0N/A ehlo-keyword = (ALPHA / DIGIT) *(ALPHA / DIGIT / "-") 0N/A ; additional syntax of ehlo-params depends on 0N/A ehlo-param = 1*(%d33-126) 0N/A ; any CHAR excluding <SP> and all 0N/A ; control characters (US-ASCII 0-31 and 127