dovecot-2.2: istream: Added internal try_alloc_limit to limit si...

dovecot at dovecot.org dovecot at dovecot.org
Sat Oct 13 00:32:47 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/cafdd35ac437
changeset: 15215:cafdd35ac437
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Oct 13 00:32:34 2012 +0300
description:
istream: Added internal try_alloc_limit to limit size returned by i_stream_try_alloc()
This was required by the previous SSL change.

diffstat:

 src/lib/istream-private.h |  2 +-
 src/lib/istream.c         |  5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diffs (27 lines):

diff -r 083bd881b9da -r cafdd35ac437 src/lib/istream-private.h
--- a/src/lib/istream-private.h	Sat Oct 13 00:24:47 2012 +0300
+++ b/src/lib/istream-private.h	Sat Oct 13 00:32:34 2012 +0300
@@ -29,7 +29,7 @@
 	unsigned char *w_buffer; /* may be NULL */
 
 	size_t buffer_size, max_buffer_size, init_buffer_size;
-	size_t skip, pos;
+	size_t skip, pos, try_alloc_limit;
 
 	struct istream *parent; /* for filter streams */
 	uoff_t parent_start_offset;
diff -r 083bd881b9da -r cafdd35ac437 src/lib/istream.c
--- a/src/lib/istream.c	Sat Oct 13 00:24:47 2012 +0300
+++ b/src/lib/istream.c	Sat Oct 13 00:32:34 2012 +0300
@@ -524,7 +524,10 @@
 	}
 
 	*size_r = stream->buffer_size - stream->pos;
-	return stream->pos != stream->buffer_size;
+	if (stream->try_alloc_limit > 0 &&
+	    *size_r > stream->try_alloc_limit)
+		*size_r = stream->try_alloc_limit;
+	return *size_r > 0;
 }
 
 void *i_stream_alloc(struct istream_private *stream, size_t size)


More information about the dovecot-cvs mailing list