[Raw Msg Headers][Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug in smtp transport agent



Hello!

There is a bug in ZMailer-2.99.15 smtp transport agent. In case of an 8 bit
e-mail is sent over an ESMTP connection just the first 8k (BUFSIZ*8) bytes
of the e-mail are transferred (only if not using MMAP system call).

Diffs for transport/smtp/smtp.c are below.

Regards
Thomas Knott

--------------------------------------------------------------------------------
*** transport/smtp/smtp.c.orig  1995/08/30 15:58:52
--- transport/smtp/smtp.c       1995/09/01 11:20:37
***************
*** 41,48 ****
  #include <sys/param.h>
  #include <sys/stat.h>
  #include NDIR_H
! #ifdef USE_ALLOCA
! # include <alloca.h>
  #endif
  
  #include <netdb.h>
--- 41,48 ----
  #include <sys/param.h>
  #include <sys/stat.h>
  #include NDIR_H
! #if defined(USE_ALLOCA) && defined(ALLOCA_H)
! # include ALLOCA_H
  #endif
  
  #include <netdb.h>
***************
*** 787,795 ****
  	else
  	  size = -hsize;
  
- 	if (lseek(dp->msgfd, dp->msgbodyoffset, SEEK_SET) < 0L)
- 	  warning("Cannot seek to message body! (%m)", (char *)NULL);
- 
  	if ((r = appendlet(dp, smtpfp[1], verboselog,
  			   hsize, size, convertmode)) != EX_OK) {
  	fail:
--- 787,792 ----
***************
*** 870,876 ****
  	register int i, rc;
  	register int bufferfull;
  	int position = dp->msgbodyoffset;
! 	int lastwasnl;
  	int lastch = '\n'; /* WriteMIMELine() can decode-QP and then the
  			      "lastwasnl" is no longer valid .. */
  
--- 867,873 ----
  	register int i, rc;
  	register int bufferfull;
  	int position = dp->msgbodyoffset;
! 	int lastwasnl = 0;
  	int lastch = '\n'; /* WriteMIMELine() can decode-QP and then the
  			      "lastwasnl" is no longer valid .. */
  
***************
*** 893,910 ****
  	    }
  	    return EX_IOERR;
  	  }
! 	  if (let_buffer[readalready-1] != '\n')
! 	    writebuf(fp, "\n", 1);
  	  if (statusreport)
  	    report("DATA %d (100%%)", readalready+hsize);
  	  if (fflush(fp) != 0)
  	    return EX_IOERR;
! 	  return EX_OK;
  	}
  #endif
! 	/* we are assumed to be positioned properly at start of message body */
  	bufferfull = 0;
- 	lastwasnl = 1;	/* we are guaranteed to have a \n after the header */
  	if (convertmode == _CONVERT_NONE) {
  #ifdef	USE_MMAP
  	  char *let_buffer = dp->let_buffer + dp->msgbodyoffset;
--- 890,907 ----
  	    }
  	    return EX_IOERR;
  	  }
!       lastwasnl = (let_buffer[readalready-1] == '\n');
  	  if (statusreport)
  	    report("DATA %d (100%%)", readalready+hsize);
  	  if (fflush(fp) != 0)
  	    return EX_IOERR;
! 
!       position += readalready;
  	}
  #endif
!     if (lseek(dp->msgfd, position, SEEK_SET) < 0L)
!       warning("Cannot seek to message body! (%m)", (char *)NULL);
  	bufferfull = 0;
  	if (convertmode == _CONVERT_NONE) {
  #ifdef	USE_MMAP
  	  char *let_buffer = dp->let_buffer + dp->msgbodyoffset;
***************
*** 1964,1970 ****
  	    smtp_isopen = 0;
  	    return EX_TEMPFAIL;
  	  } else {
! 	    sprintf(remotemsg, "500 (Server hung up on us! Cmd: %s)",strbuf);
  	    notaryreport(NULL,NULL,remotemsg);
  	    dflag = 0;
  	    if (verboselog)
--- 1961,1968 ----
  	    smtp_isopen = 0;
  	    return EX_TEMPFAIL;
  	  } else {
! 	    sprintf(remotemsg, "500 (Server hung up on us! Cmd: %s)",
!             (strbuf == NULL) ? "(null cmd)" : strbuf);
  	    notaryreport(NULL,NULL,remotemsg);
  	    dflag = 0;
  	    if (verboselog)