dovecot-2.1: fts: Fixed crash in fts_lookup_multi() for backends...

dovecot at dovecot.org dovecot at dovecot.org
Wed Aug 1 20:24:10 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.1/rev/8d59874e02ad
changeset: 14647:8d59874e02ad
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Aug 01 20:24:00 2012 +0300
description:
fts: Fixed crash in fts_lookup_multi() for backends that can't handle it (fts-squat)

diffstat:

 src/plugins/fts/fts-api.c |  17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

diffs (29 lines):

diff -r 8029f1b4afd0 -r 8d59874e02ad src/plugins/fts/fts-api.c
--- a/src/plugins/fts/fts-api.c	Wed Aug 01 14:13:40 2012 +0300
+++ b/src/plugins/fts/fts-api.c	Wed Aug 01 20:24:00 2012 +0300
@@ -318,9 +318,24 @@
 			     struct mail_search_arg *args, bool and_args,
 			     struct fts_multi_result *result)
 {
+	unsigned int i;
+
 	i_assert(boxes[0] != NULL);
 
-	return backend->v.lookup_multi(backend, boxes, args, and_args, result);
+	if (backend->v.lookup_multi != NULL) {
+		return backend->v.lookup_multi(backend, boxes, args,
+					       and_args, result);
+	}
+
+	for (i = 0; boxes[i] != NULL; i++) ;
+	result->box_results = p_new(result->pool, struct fts_result, i+1);
+
+	for (i = 0; boxes[i] != NULL; i++) {
+		if (backend->v.lookup(backend, boxes[i], args,
+				      and_args, &result->box_results[i]) < 0)
+			return -1;
+	}
+	return 0;
 }
 
 void fts_backend_lookup_done(struct fts_backend *backend)


More information about the dovecot-cvs mailing list