dovecot-1.2: Transaction view: lookup_ext() crashed if extension...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Sep 11 23:16:31 EEST 2008
details: http://hg.dovecot.org/dovecot-1.2/rev/32aa972895cc
changeset: 8192:32aa972895cc
user: Timo Sirainen <tss at iki.fi>
date: Thu Sep 11 23:16:27 2008 +0300
description:
Transaction view: lookup_ext() crashed if extension was just being added within the transaction.
diffstat:
1 file changed, 24 insertions(+), 4 deletions(-)
src/lib-index/mail-index-transaction-view.c | 28 +++++++++++++++++++++++----
diffs (44 lines):
diff -r f14e68845b6b -r 32aa972895cc src/lib-index/mail-index-transaction-view.c
--- a/src/lib-index/mail-index-transaction-view.c Thu Sep 11 18:47:19 2008 +0300
+++ b/src/lib-index/mail-index-transaction-view.c Thu Sep 11 23:16:27 2008 +0300
@@ -194,16 +194,36 @@ tview_return_updated_ext(struct mail_ind
const void *data, uint32_t ext_id)
{
const struct mail_index_ext *ext;
+ const struct mail_index_registered_ext *rext;
+ const struct mail_transaction_ext_intro *intro;
+ unsigned int record_align, record_size;
uint32_t ext_idx;
/* data begins with a 32bit sequence, followed by the actual
extension data */
data = CONST_PTR_OFFSET(data, sizeof(uint32_t));
- if (!mail_index_map_get_ext_idx(tview->lookup_map, ext_id, &ext_idx))
- i_unreached();
-
- ext = array_idx(&tview->lookup_map->extensions, ext_idx);
+ if (!mail_index_map_get_ext_idx(tview->lookup_map, ext_id, &ext_idx)) {
+ /* we're adding the extension now. */
+ rext = array_idx(&tview->view.index->extensions, ext_id);
+ record_align = ext->record_align;
+ record_size = ext->record_size;
+ } else {
+ ext = array_idx(&tview->lookup_map->extensions, ext_idx);
+ record_align = ext->record_align;
+ record_size = ext->record_size;
+ }
+
+ /* see if the extension has been resized within this transaction */
+ if (array_is_created(&tview->t->ext_resizes) &&
+ ext_id < array_count(&tview->t->ext_resizes)) {
+ intro = array_idx(&tview->t->ext_resizes, ext_id);
+ if (intro[ext_id].name_size != 0) {
+ record_align = intro->record_align;
+ record_size = intro->record_size;
+ }
+ }
+
if (ext->record_align <= sizeof(uint32_t)) {
/* data is 32bit aligned already */
return data;
More information about the dovecot-cvs
mailing list