From 64056bdc7324369ae3a58df156521453396a2cb2 Mon Sep 17 00:00:00 2001 From: Janos SUTO Date: Wed, 30 Aug 2017 17:35:19 +0200 Subject: [PATCH] src: bdat fix Signed-off-by: Janos SUTO --- src/bdat.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/bdat.c b/src/bdat.c index 1773206f..87abc30a 100644 --- a/src/bdat.c +++ b/src/bdat.c @@ -55,7 +55,7 @@ void get_bdat_size_to_read(struct smtp_session *session, char *buf){ if(!p || session->bdat_bytes_to_read <= 0){ session->bdat_bytes_to_read = 0; - syslog(LOG_INFO, "%s: malformed BDAT command", session->ttmpfile); + syslog(LOG_INFO, "%s: ERROR: malformed BDAT command", session->ttmpfile); } } @@ -66,8 +66,6 @@ void process_bdat(struct smtp_session *session, char *readbuf, int readlen){ if(readlen <= 0) return; - //printf("readbuf in process_bdat (%d): *%s*\n", readlen, readbuf); - if(session->bdat_rounds == 1){ session->fd = open(session->ttmpfile, O_CREAT|O_RDWR, S_IRUSR|S_IWUSR|S_IRGRP); if(session->fd == -1){ @@ -78,10 +76,12 @@ void process_bdat(struct smtp_session *session, char *readbuf, int readlen){ session->bdat_bytes_to_read -= readlen; if(session->fd != -1){ - if(write(session->fd, readbuf, readlen) == -1) syslog(LOG_PRIORITY, "ERROR: write(), %s, %d, %s", __func__, __LINE__, __FILE__); - session->tot_len += readlen; + if(write(session->fd, readbuf, readlen) != -1){ + session->tot_len += readlen; - if(session->cfg->verbosity >= _LOG_DEBUG) syslog(LOG_INFO, "%s: wrote %d bytes, %d bytes to go", session->ttmpfile, readlen, session->bdat_bytes_to_read); + if(session->cfg->verbosity >= _LOG_DEBUG) syslog(LOG_INFO, "%s: wrote %d bytes, %d bytes to go", session->ttmpfile, readlen, session->bdat_bytes_to_read); + } + else syslog(LOG_PRIORITY, "ERROR: write(), %s, %d, %s", __func__, __LINE__, __FILE__); }