dovecot-2.2-pigeonhole: lib-sieve: message body: Prevent cached ...
pigeonhole at rename-it.nl
pigeonhole at rename-it.nl
Mon Dec 28 19:46:19 UTC 2015
details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/450c272a57c0
changeset: 2181:450c272a57c0
user: Stephan Bosch <stephan at rename-it.nl>
date: Mon Dec 28 20:46:14 2015 +0100
description:
lib-sieve: message body: Prevent cached raw body from growing by one '\0' each time it is accessed.
diffstat:
src/lib-sieve/sieve-message.c | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diffs (36 lines):
diff -r 24308c4d6263 -r 450c272a57c0 src/lib-sieve/sieve-message.c
--- a/src/lib-sieve/sieve-message.c Mon Dec 28 20:33:01 2015 +0100
+++ b/src/lib-sieve/sieve-message.c Mon Dec 28 20:46:14 2015 +0100
@@ -1499,6 +1499,10 @@
i_stream_get_error(input));
return SIEVE_EXEC_TEMP_FAILURE;
}
+
+ /* Add terminating NUL to the body part buffer */
+ buffer_append_c(buf, '\0');
+
} else {
buf = msgctx->raw_body;
}
@@ -1506,14 +1510,16 @@
/* Clear result array */
array_clear(&msgctx->return_body_parts);
- if ( buf->used > 0 ) {
- /* Add terminating NUL to the body part buffer */
- buffer_append_c(buf, '\0');
+ if ( buf->used > 1 ) {
+ const char *data = (const char *)buf->data;
+ size_t size = buf->used - 1;
+
+ i_assert( data[size] == '\0' );
/* Add single item to the result */
return_part = array_append_space(&msgctx->return_body_parts);
- return_part->content = buf->data;
- return_part->size = buf->used - 1;
+ return_part->content = data;
+ return_part->size = size;
}
/* Return the array of body items */
More information about the dovecot-cvs
mailing list