dovecot-2.2: ostream-rawlog: Make sure rawlog logs only the data...

dovecot at dovecot.org dovecot at dovecot.org
Wed Nov 28 02:35:44 EET 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/b10fbe79f619
changeset: 15424:b10fbe79f619
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Nov 28 02:35:37 2012 +0200
description:
ostream-rawlog: Make sure rawlog logs only the data that got actually sent.

diffstat:

 src/lib/ostream-rawlog.c |  19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)

diffs (34 lines):

diff -r 9bff748f3437 -r b10fbe79f619 src/lib/ostream-rawlog.c
--- a/src/lib/ostream-rawlog.c	Wed Nov 28 02:35:15 2012 +0200
+++ b/src/lib/ostream-rawlog.c	Wed Nov 28 02:35:37 2012 +0200
@@ -24,17 +24,24 @@
 {
 	struct rawlog_ostream *rstream = (struct rawlog_ostream *)stream;
 	unsigned int i;
-	ssize_t ret;
-
-	for (i = 0; i < iov_count; i++) {
-		iostream_rawlog_write(&rstream->riostream,
-				      iov[i].iov_base, iov[i].iov_len);
-	}
+	ssize_t ret, bytes;
 
 	if ((ret = o_stream_sendv(stream->parent, iov, iov_count)) < 0) {
 		o_stream_copy_error_from_parent(stream);
 		return -1;
 	}
+	bytes = ret;
+	for (i = 0; i < iov_count && bytes > 0; i++) {
+		if (iov[i].iov_len < (size_t)bytes) {
+			iostream_rawlog_write(&rstream->riostream,
+					      iov[i].iov_base, iov[i].iov_len);
+			bytes -= iov[i].iov_len;
+		} else {
+			iostream_rawlog_write(&rstream->riostream,
+					      iov[i].iov_base, bytes);
+			break;
+		}
+	}
 
 	stream->ostream.offset += ret;
 	return ret;


More information about the dovecot-cvs mailing list