mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-24 19:10:13 +01:00
Fixed reading a line from smtp data stage
Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
parent
03c22264ea
commit
4fd0fd25c5
@ -186,27 +186,34 @@ 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;
|
||||||
|
|
||||||
|
// complete line: rc == OK and puflen > 0
|
||||||
|
// incomplete line with something in the buffer: rc == ERR and puflen > 0
|
||||||
|
|
||||||
if(puflen > 0){
|
if(puflen > 0){
|
||||||
// Update lasttime if we have a line to process
|
// Update lasttime if we have a line to process
|
||||||
time(&(session->lasttime));
|
time(&(session->lasttime));
|
||||||
|
|
||||||
// pass the puffer to process_data() only if there was an '\n'
|
// Save incomplete line to buffer
|
||||||
// on the line or the puffer does not start with a period
|
if(rc == ERR){
|
||||||
if(session->protocol_state == SMTP_STATE_DATA && (rc == OK || puf[0] != '.')){
|
snprintf(session->buf, sizeof(session->buf)-1, "%s", puf);
|
||||||
sig_block(SIGALRM);
|
|
||||||
process_data(session, puf, puflen);
|
|
||||||
sig_unblock(SIGALRM);
|
|
||||||
}
|
|
||||||
else if(session->protocol_state == SMTP_STATE_BDAT){
|
|
||||||
process_bdat(session, puf, puflen, cfg);
|
|
||||||
}
|
|
||||||
else if(rc == OK){
|
|
||||||
process_smtp_command(session, puf, cfg);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
snprintf(session->buf, MAXBUFSIZE-1, "%s", puf);
|
|
||||||
session->buflen = puflen;
|
session->buflen = puflen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We have a complete line to process
|
||||||
|
|
||||||
|
if(rc == OK){
|
||||||
|
if(session->protocol_state == SMTP_STATE_BDAT){
|
||||||
|
process_bdat(session, puf, puflen, cfg);
|
||||||
|
}
|
||||||
|
else if(session->protocol_state == SMTP_STATE_DATA){
|
||||||
|
sig_block(SIGALRM);
|
||||||
|
process_data(session, puf, puflen);
|
||||||
|
sig_unblock(SIGALRM);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
process_smtp_command(session, puf, cfg);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} while(puflen > 0);
|
} while(puflen > 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user