dovecot-2.2: lmtp proxy: Make sure DATA stream size doesn't chan...

dovecot at dovecot.org dovecot at dovecot.org
Fri Jun 27 11:08:22 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/1b9356dbfca2
changeset: 17523:1b9356dbfca2
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Jun 27 14:06:56 2014 +0300
description:
lmtp proxy: Make sure DATA stream size doesn't change unexpectedly.

diffstat:

 src/lmtp/lmtp-proxy.c |  12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diffs (43 lines):

diff -r 1495857f0698 -r 1b9356dbfca2 src/lmtp/lmtp-proxy.c
--- a/src/lmtp/lmtp-proxy.c	Fri Jun 27 14:06:08 2014 +0300
+++ b/src/lmtp/lmtp-proxy.c	Fri Jun 27 14:06:56 2014 +0300
@@ -4,6 +4,7 @@
 #include "array.h"
 #include "ioloop.h"
 #include "istream.h"
+#include "istream-sized.h"
 #include "ostream.h"
 #include "lmtp-client.h"
 #include "lmtp-proxy.h"
@@ -294,6 +295,7 @@
 		      lmtp_proxy_finish_callback_t *callback, void *context)
 {
 	struct lmtp_proxy_connection *const *conns;
+	uoff_t size;
 
 	i_assert(data_input->seekable);
 	i_assert(proxy->data_input == NULL);
@@ -302,6 +304,11 @@
 	proxy->finish_context = context;
 	proxy->data_input = data_input;
 	i_stream_ref(proxy->data_input);
+	if (i_stream_get_size(proxy->data_input, TRUE, &size) < 0) {
+		i_error("i_stream_get_size(data_input) failed: %s",
+			i_stream_get_error(proxy->data_input));
+		size = (uoff_t)-1;
+	}
 
 	/* create the data_input streams first */
 	array_foreach(&proxy->connections, conns) {
@@ -314,7 +321,10 @@
 
 		conn->to = timeout_add(proxy->max_timeout_msecs,
 				       lmtp_proxy_conn_timeout, conn);
-		conn->data_input = i_stream_create_limit(data_input, (uoff_t)-1);
+		if (size == (uoff_t)-1)
+			conn->data_input = i_stream_create_limit(data_input, (uoff_t)-1);
+		else
+			conn->data_input = i_stream_create_sized(data_input, size);
 	}
 	/* now that all the streams are created, start reading them
 	   (reading them earlier could have caused the data_input parent's


More information about the dovecot-cvs mailing list