dovecot-2.2: lib: test-array - fix off-by-one in test_reverse

dovecot at dovecot.org dovecot at dovecot.org
Tue Nov 25 01:54:06 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/e9ac32255ef1
changeset: 18114:e9ac32255ef1
user:      Phil Carmody <phil at dovecot.fi>
date:      Tue Nov 25 03:45:35 2014 +0200
description:
lib: test-array - fix off-by-one in test_reverse
i is not used as an index, but as a count. Therefore, it can attain the
array size in the loop without causing any buffer overflows.

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

diffstat:

 src/lib/test-array.c |  2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diffs (12 lines):

diff -r 9141a16aff4e -r e9ac32255ef1 src/lib/test-array.c
--- a/src/lib/test-array.c	Tue Nov 25 03:44:55 2014 +0200
+++ b/src/lib/test-array.c	Tue Nov 25 03:45:35 2014 +0200
@@ -41,7 +41,7 @@
 
 	test_begin("array reverse");
 	t_array_init(&intarr, 5);
-	for (i = 0; i < N_ELEMENTS(input); i++) {
+	for (i = 0; i <= N_ELEMENTS(input); i++) {
 		array_clear(&intarr);
 		array_append(&intarr, input, i);
 		array_reverse(&intarr);


More information about the dovecot-cvs mailing list