mirror of
				https://bitbucket.org/jsuto/piler.git
				synced 2025-11-04 04:22:26 +01:00 
			
		
		
		
	fix handling partial lines in DATA stage
Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
		@@ -391,6 +391,7 @@ struct smtp_session {
 | 
			
		||||
   int fd;
 | 
			
		||||
   int bad;
 | 
			
		||||
   int buflen;
 | 
			
		||||
   int last_data_char;
 | 
			
		||||
   int tot_len;
 | 
			
		||||
   int bdat_rounds;
 | 
			
		||||
   int bdat_last_round;
 | 
			
		||||
 
 | 
			
		||||
@@ -55,7 +55,7 @@ void usage(){
 | 
			
		||||
void p_clean_exit(int sig){
 | 
			
		||||
   int i;
 | 
			
		||||
 | 
			
		||||
   syslog(LOG_PRIORITY, "got signal: %d, %s", sig, strsignal(sig));
 | 
			
		||||
   if(sig > 0) syslog(LOG_PRIORITY, "got signal: %d, %s", sig, strsignal(sig));
 | 
			
		||||
 | 
			
		||||
   if(listenerfd != -1) close(listenerfd);
 | 
			
		||||
 | 
			
		||||
@@ -190,10 +190,11 @@ int main(int argc, char **argv){
 | 
			
		||||
 | 
			
		||||
   set_signal_handler(SIGINT, p_clean_exit);
 | 
			
		||||
   set_signal_handler(SIGTERM, p_clean_exit);
 | 
			
		||||
 | 
			
		||||
   set_signal_handler(SIGKILL, p_clean_exit);
 | 
			
		||||
   set_signal_handler(SIGSEGV, p_clean_exit);
 | 
			
		||||
 | 
			
		||||
   set_signal_handler(SIGPIPE, SIG_IGN);
 | 
			
		||||
 | 
			
		||||
   set_signal_handler(SIGALRM, check_for_client_timeout);
 | 
			
		||||
   set_signal_handler(SIGHUP, initialise_configuration);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -119,6 +119,8 @@ void init_smtp_session(struct smtp_session *session, int slot, int sd, struct co
 | 
			
		||||
   session->net.ctx = NULL;
 | 
			
		||||
   session->net.ssl = NULL;
 | 
			
		||||
 | 
			
		||||
   session->last_data_char = 0;
 | 
			
		||||
 | 
			
		||||
   session->fd = -1;
 | 
			
		||||
 | 
			
		||||
   memset(session->mailfrom, 0, SMALLBUFSIZE);
 | 
			
		||||
 
 | 
			
		||||
@@ -71,7 +71,7 @@ void process_smtp_command(struct smtp_session *session, char *buf, struct config
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void process_data(struct smtp_session *session, char *buf, int buflen){
 | 
			
		||||
   if(strcmp(buf, ".\r\n") == 0){
 | 
			
		||||
   if(session->last_data_char == '\n' && strcmp(buf, ".\r\n") == 0){
 | 
			
		||||
      process_command_period(session);
 | 
			
		||||
   }
 | 
			
		||||
   else {
 | 
			
		||||
@@ -81,6 +81,8 @@ void process_data(struct smtp_session *session, char *buf, int buflen){
 | 
			
		||||
      }
 | 
			
		||||
      else syslog(LOG_PRIORITY, "ERROR (line: %d) process_data(): failed to write %d bytes", __LINE__, buflen);
 | 
			
		||||
   }
 | 
			
		||||
 | 
			
		||||
   session->last_data_char = buf[buflen-1];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -280,6 +282,7 @@ void process_command_period(struct smtp_session *session){
 | 
			
		||||
   snprintf(buf, sizeof(buf)-1, "250 OK <%s>\r\n", session->ttmpfile);
 | 
			
		||||
 | 
			
		||||
   session->buflen = 0;
 | 
			
		||||
   session->last_data_char = 0;
 | 
			
		||||
   memset(session->buf, 0, SMALLBUFSIZE);
 | 
			
		||||
 | 
			
		||||
   send_smtp_response(session, buf);
 | 
			
		||||
@@ -301,6 +304,7 @@ void process_command_reset(struct smtp_session *session){
 | 
			
		||||
   session->tot_len = 0;
 | 
			
		||||
   session->fd = -1;
 | 
			
		||||
   session->protocol_state = SMTP_STATE_HELO;
 | 
			
		||||
   session->last_data_char = 0;
 | 
			
		||||
 | 
			
		||||
   reset_bdat_counters(session);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user