simplified handle_data()

Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
Janos SUTO 2018-03-04 19:50:37 +01:00
parent a48e3c74df
commit 1d0019ff35

View File

@ -169,7 +169,7 @@ void tear_down_session(struct smtp_session **sessions, int slot, int *num_connec
void handle_data(struct smtp_session *session, char *readbuf, int readlen, struct config *cfg){ void handle_data(struct smtp_session *session, char *readbuf, int readlen, struct config *cfg){
int puflen, rc, lines=0; int puflen, rc;
char *p, copybuf[BIGBUFSIZE+MAXBUFSIZE], puf[MAXBUFSIZE]; char *p, copybuf[BIGBUFSIZE+MAXBUFSIZE], puf[MAXBUFSIZE];
// if there's something in the saved buffer, then let's merge them // if there's something in the saved buffer, then let's merge them
@ -194,32 +194,16 @@ void handle_data(struct smtp_session *session, char *readbuf, int readlen, struc
puflen = read_one_line(p, '\n', puf, sizeof(puf)-1, &rc); puflen = read_one_line(p, '\n', puf, sizeof(puf)-1, &rc);
p += puflen; p += puflen;
lines++; if(puflen > 0){
if(session->protocol_state == SMTP_STATE_DATA){
if(rc == OK){
if(session->protocol_state == SMTP_STATE_BDAT){
if(session->bad == 1){
// something bad happened in the BDAT processing
return;
}
process_bdat(session, puf, puflen, cfg);
}
else if(session->protocol_state == SMTP_STATE_DATA){
process_data(session, puf, puflen); process_data(session, puf, puflen);
} }
else if(session->protocol_state == SMTP_STATE_BDAT){
else {
process_smtp_command(session, puf, cfg);
}
}
else if(puflen > 0){
// if it's BDAT state, then don't buffer, rather give it to
// the BDAT processing function
if(session->protocol_state == SMTP_STATE_BDAT){
process_bdat(session, puf, puflen, cfg); process_bdat(session, puf, puflen, cfg);
} }
else if(rc == OK){
process_smtp_command(session, puf, cfg);
}
else { else {
snprintf(session->buf, MAXBUFSIZE-1, "%s", puf); snprintf(session->buf, MAXBUFSIZE-1, "%s", puf);
session->buflen = puflen; session->buflen = puflen;