mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-24 19:30:12 +01:00
Fixed handling dot stuffing in the DATA stage of the smtp chat
Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
parent
62fcb37606
commit
0b18c6060f
15
src/smtp.c
15
src/smtp.c
@ -85,12 +85,21 @@ void process_data(struct smtp_session *session, char *buf, int buflen){
|
||||
int written=0, n_writes=0;
|
||||
|
||||
while(written < buflen) {
|
||||
int len = write(session->fd, buf+written, buflen-written);
|
||||
// In the DATA phase skip the 1st character if it's a dot (.)
|
||||
// and there are more characters before the trailing CR-LF
|
||||
//
|
||||
// See https://www.ietf.org/rfc/rfc5321.html#section-4.5.2 for more.
|
||||
|
||||
int dotstuff = 0;
|
||||
if(*buf == '.' && buflen > 1 && *(buf+1) != '\r' && *(buf+1) != '\n') dotstuff = 1;
|
||||
|
||||
int len = write(session->fd, buf+dotstuff+written, buflen-dotstuff-written);
|
||||
|
||||
n_writes++;
|
||||
|
||||
if(len > 0){
|
||||
if(len != buflen) syslog(LOG_PRIORITY, "WARN: partial write: %d/%d bytes (round: %d)", len, buflen, n_writes);
|
||||
written += len;
|
||||
if(len != buflen-dotstuff) syslog(LOG_PRIORITY, "WARN: partial write: %d/%d bytes (round: %d)", len, buflen-dotstuff, n_writes);
|
||||
written += len + dotstuff;
|
||||
session->tot_len += len;
|
||||
}
|
||||
else syslog(LOG_PRIORITY, "ERROR (line: %d) process_data(): written %d bytes", __LINE__, len);
|
||||
|
Loading…
Reference in New Issue
Block a user