mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-24 19:00:11 +01:00
BDAT fixes
Change-Id: Ifd5f7342378a2feddafa1faba69645107bee90a1 Signed-off-by: SJ <sj@acts.hu>
This commit is contained in:
parent
02bc3cffa7
commit
8695663104
@ -261,13 +261,14 @@ AFTER_PERIOD:
|
||||
|
||||
|
||||
if(cfg->enable_chunking == 1 && strncasecmp(buf, SMTP_CMD_BDAT, strlen(SMTP_CMD_BDAT)) == 0){
|
||||
|
||||
process_command_bdat(sctx, &sdata, data, &protocol_state, buf, &resp[0], sizeof(resp)-1);
|
||||
|
||||
if(protocol_state == SMTP_STATE_BDAT){
|
||||
snprintf(resp, sizeof(resp)-2, "250 octets received\r\n");
|
||||
|
||||
for(i=0; i<sctx->bdat_rounds-1; i++){
|
||||
send_buffered_response(&sdata, data, starttls, sctx->new_sd, &resp[0], cfg);
|
||||
syslog(LOG_INFO, "%d, sending bdat response", i);
|
||||
write1(sctx->new_sd, "250 octets received\r\n", strlen("250 octets received\r\n"), sdata.tls, data->ssl);
|
||||
}
|
||||
|
||||
process_written_file(sctx, &sdata, data, cfg);
|
||||
|
10
src/smtp.c
10
src/smtp.c
@ -138,7 +138,7 @@ void process_command_bdat(struct session_ctx *sctx, struct session_data *sdata,
|
||||
int n, expected_bdat_len;
|
||||
char puf[MAXBUFSIZE];
|
||||
|
||||
if(*protocol_state == SMTP_STATE_RCPT_TO){
|
||||
if(*protocol_state != SMTP_STATE_RCPT_TO){
|
||||
strncat(resp, SMTP_RESP_503_ERR, resplen);
|
||||
return;
|
||||
}
|
||||
@ -166,15 +166,15 @@ void process_command_bdat(struct session_ctx *sctx, struct session_data *sdata,
|
||||
else if(sctx->bdat_last_round != 1){
|
||||
if((n = recvtimeoutssl(sctx->new_sd, &puf[0], sizeof(puf), TIMEOUT, sdata->tls, data->ssl)) > 0){
|
||||
expected_bdat_len = extract_bdat_command(sctx, sdata, puf);
|
||||
if(expected_bdat_len <= 0 && sctx->bdat_rounds > 0) sctx->bdat_rounds--;
|
||||
}
|
||||
}
|
||||
|
||||
if(expected_bdat_len > 0) sdata->tot_len += read_bdat_data(sctx, sdata, data, expected_bdat_len);
|
||||
}
|
||||
|
||||
close(sdata->fd);
|
||||
fsync(sdata->fd);
|
||||
|
||||
close(sdata->fd);
|
||||
}
|
||||
|
||||
|
||||
@ -184,7 +184,7 @@ int extract_bdat_command(struct session_ctx *sctx, struct session_data *sdata, c
|
||||
|
||||
// determine if this is the last BDAT command
|
||||
|
||||
p = strstr(buf, " LAST");
|
||||
p = strcasestr(buf, " LAST");
|
||||
if(p){
|
||||
sctx->bdat_last_round = 1;
|
||||
syslog(LOG_INFO, "%s: BDAT LAST", sdata->ttmpfile);
|
||||
@ -219,6 +219,8 @@ int read_bdat_data(struct session_ctx *sctx, struct session_data *sdata, struct
|
||||
}
|
||||
}
|
||||
|
||||
syslog(LOG_INFO, "%s: wrote %d bytes of BDAT data", sdata->ttmpfile, written_bdat_len);
|
||||
|
||||
return written_bdat_len;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user