dovecot-2.2: lib: data-stack - start sentry checks immediately a...

dovecot at dovecot.org dovecot at dovecot.org
Mon Jul 28 13:54:29 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/9bf0c6d936ef
changeset: 17653:9bf0c6d936ef
user:      Phil Carmody <phil at dovecot.fi>
date:      Mon Jul 28 16:45:33 2014 +0300
description:
lib: data-stack - start sentry checks immediately after the reserved buffer
Our sentries are written with byte-precision, no need to round up before
doing the checks.

Signed-off-by: Phil Carmody <phil at dovecot.fi>

diffstat:

 src/lib/data-stack.c |  12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

diffs (32 lines):

diff -r e33102604242 -r 9bf0c6d936ef src/lib/data-stack.c
--- a/src/lib/data-stack.c	Mon Jul 28 16:45:33 2014 +0300
+++ b/src/lib/data-stack.c	Mon Jul 28 16:45:33 2014 +0300
@@ -101,12 +101,11 @@
 {
 	if (last_buffer_block != NULL) {
 #ifdef DEBUG
-		unsigned char *last_alloc_end, *p;
-		unsigned int i;
+		unsigned char *last_alloc_end, *p, *pend;
 
 		last_alloc_end = data_stack_after_last_alloc(current_block);
-		p = last_alloc_end + MEM_ALIGN(sizeof(size_t)) + MEM_ALIGN(last_buffer_size);
-
+		p = last_alloc_end + MEM_ALIGN(sizeof(size_t)) + last_buffer_size;
+		pend = last_alloc_end + ALLOC_SIZE(last_buffer_size);
 #endif
 		/* reset t_buffer_get() mark - not really needed but makes it
 		   easier to notice if t_malloc()/t_push()/t_pop() is called
@@ -116,10 +115,9 @@
 		last_buffer_block = NULL;
 
 #ifdef DEBUG
-		for (i = 0; i < SENTRY_COUNT; i++) {
-			if (p[i] != CLEAR_CHR)
+		while (p < pend)
+			if (*p++ != CLEAR_CHR)
 				i_panic("t_buffer_get(): buffer overflow");
-		}
 
 		if (!preserve_data) {
 			p = last_alloc_end;


More information about the dovecot-cvs mailing list