dovecot-2.2: dbox: Added asserts to dbox file fixing to make sur...
dovecot at dovecot.org
dovecot at dovecot.org
Fri Jun 13 00:10:36 UTC 2014
details: http://hg.dovecot.org/dovecot-2.2/rev/03520d887a4f
changeset: 17483:03520d887a4f
user: Timo Sirainen <tss at iki.fi>
date: Fri Jun 13 03:09:26 2014 +0300
description:
dbox: Added asserts to dbox file fixing to make sure it doesn't go to infinite loop.
There apparently is a bug in here that will trigger this assert.
diffstat:
src/lib-storage/index/dbox-common/dbox-file-fix.c | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diffs (32 lines):
diff -r 53742463a9fe -r 03520d887a4f src/lib-storage/index/dbox-common/dbox-file-fix.c
--- a/src/lib-storage/index/dbox-common/dbox-file-fix.c Fri Jun 13 02:54:21 2014 +0300
+++ b/src/lib-storage/index/dbox-common/dbox-file-fix.c Fri Jun 13 03:09:26 2014 +0300
@@ -140,19 +140,24 @@
magic markers. */
struct istream *input = file->input;
- uoff_t orig_offset, pre_offset, post_offset;
+ uoff_t orig_offset, pre_offset, post_offset, prev_offset;
const unsigned char *data, *magic;
- size_t size, need_bytes;
+ size_t size, need_bytes, prev_need_bytes;
int ret, match;
*pre_r = FALSE;
- orig_offset = input->v_offset;
- need_bytes = strlen(DBOX_MAGIC_POST);
+ orig_offset = prev_offset = input->v_offset;
+ need_bytes = strlen(DBOX_MAGIC_POST); prev_need_bytes = 0;
while ((ret = i_stream_read_data(input, &data, &size, need_bytes-1)) > 0 ||
ret == -2) {
/* search for the beginning of a potential pre/post magic */
i_assert(size > 1);
+ i_assert(prev_offset != input->v_offset ||
+ need_bytes > prev_need_bytes);
+ prev_offset = input->v_offset;
+ prev_need_bytes = need_bytes;
+
magic = memchr(data, DBOX_MAGIC_PRE[0], size);
if (magic == NULL) {
i_stream_skip(input, size-1);
More information about the dovecot-cvs
mailing list