dovecot-2.2: lib-fs: If fs_default_copy() fails, close the copy ...

dovecot at dovecot.org dovecot at dovecot.org
Sat Jun 1 17:09:00 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/09a57e2f07df
changeset: 16446:09a57e2f07df
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Jun 01 17:08:19 2013 +0300
description:
lib-fs: If fs_default_copy() fails, close the copy stream immediately.
The stream's origin may already be freed by the time the fs_file_close() is
trying to close the stream.

diffstat:

 src/lib-fs/fs-api.c |  4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diffs (20 lines):

diff -r 05b6cd9220de -r 09a57e2f07df src/lib-fs/fs-api.c
--- a/src/lib-fs/fs-api.c	Sat Jun 01 15:33:58 2013 +0300
+++ b/src/lib-fs/fs-api.c	Sat Jun 01 17:08:19 2013 +0300
@@ -552,12 +552,16 @@
 		errno = dest->copy_input->stream_errno;
 		fs_set_error(dest->fs, "read(%s) failed: %m",
 			     i_stream_get_name(dest->copy_input));
+		i_stream_unref(&dest->copy_input);
+		fs_write_stream_abort(dest, &dest->copy_output);
 		return -1;
 	}
 	if (dest->copy_output->stream_errno != 0) {
 		errno = dest->copy_output->stream_errno;
 		fs_set_error(dest->fs, "write(%s) failed: %m",
 			     o_stream_get_name(dest->copy_output));
+		i_stream_unref(&dest->copy_input);
+		fs_write_stream_abort(dest, &dest->copy_output);
 		return -1;
 	}
 	if (!dest->copy_input->eof) {


More information about the dovecot-cvs mailing list