dovecot-2.2: lib-storage: Fixed crash if mailbox_save_cancel() w...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Apr 29 10:36:27 UTC 2014
details: http://hg.dovecot.org/dovecot-2.2/rev/db216ddbb5c2
changeset: 17289:db216ddbb5c2
user: Timo Sirainen <tss at iki.fi>
date: Tue Apr 29 13:35:06 2014 +0300
description:
lib-storage: Fixed crash if mailbox_save_cancel() was called in save_finish()/copy() method.
diffstat:
src/lib-storage/mail-storage-private.h | 2 ++
src/lib-storage/mail-storage.c | 7 ++++++-
2 files changed, 8 insertions(+), 1 deletions(-)
diffs (45 lines):
diff -r 4e3a518f6fcd -r db216ddbb5c2 src/lib-storage/mail-storage-private.h
--- a/src/lib-storage/mail-storage-private.h Tue Apr 29 13:10:28 2014 +0300
+++ b/src/lib-storage/mail-storage-private.h Tue Apr 29 13:35:06 2014 +0300
@@ -559,6 +559,8 @@
/* mailbox_save_alloc() called, but finish/cancel not.
the same context is usually returned by the backends for reuse. */
unsigned int unfinished:1;
+ /* mailbox_save_finish() or mailbox_copy() is being called. */
+ unsigned int finishing:1;
/* mail was copied using saving */
unsigned int copying_via_save:1;
/* mail is being saved, not copied */
diff -r 4e3a518f6fcd -r db216ddbb5c2 src/lib-storage/mail-storage.c
--- a/src/lib-storage/mail-storage.c Tue Apr 29 13:10:28 2014 +0300
+++ b/src/lib-storage/mail-storage.c Tue Apr 29 13:35:06 2014 +0300
@@ -2081,7 +2081,10 @@
}
*_ctx = NULL;
+ ctx->finishing = TRUE;
ret = t->box->v.save_finish(ctx);
+ ctx->finishing = FALSE;
+
if (ret == 0 && !copying_via_save) {
if (pvt_flags != 0)
mailbox_save_add_pvt_flags(t, pvt_flags);
@@ -2102,7 +2105,7 @@
*_ctx = NULL;
ctx->transaction->box->v.save_cancel(ctx);
- if (keywords != NULL)
+ if (keywords != NULL && !ctx->finishing)
mailbox_keywords_unref(&keywords);
if (ctx->dest_mail != NULL) {
/* the dest_mail is no longer valid. if we're still saving
@@ -2144,7 +2147,9 @@
mailbox_save_cancel(&ctx);
return -1;
}
+ ctx->finishing = TRUE;
ret = t->box->v.copy(ctx, backend_mail);
+ ctx->finishing = FALSE;
if (ret == 0) {
if (pvt_flags != 0)
mailbox_save_add_pvt_flags(t, pvt_flags);
More information about the dovecot-cvs
mailing list