dovecot-2.2: o_stream_send_istream(): Fixed copying within same ...
dovecot at dovecot.org
dovecot at dovecot.org
Wed Jan 9 05:43:21 EET 2013
details: http://hg.dovecot.org/dovecot-2.2/rev/3d3625d18231
changeset: 15610:3d3625d18231
user: Timo Sirainen <tss at iki.fi>
date: Wed Jan 09 05:28:58 2013 +0200
description:
o_stream_send_istream(): Fixed copying within same file, when istream's size is unknown.
This fixes copying a mail from mdbox's m.* file to the end of the same file.
diffstat:
src/lib/ostream-file.c | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
diffs (29 lines):
diff -r 7bbc5c50c309 -r 3d3625d18231 src/lib/ostream-file.c
--- a/src/lib/ostream-file.c Wed Jan 09 05:29:13 2013 +0200
+++ b/src/lib/ostream-file.c Wed Jan 09 05:28:58 2013 +0200
@@ -814,16 +814,22 @@
{
struct file_ostream *foutstream = (struct file_ostream *)outstream;
uoff_t in_size;
- off_t in_abs_offset, ret;
+ off_t in_abs_offset, ret = 0;
if (same_stream) {
/* copying data within same fd. we'll have to be careful with
seeks and overlapping writes. */
- if ((ret = i_stream_get_size(instream, TRUE, &in_size)) <= 0) {
- outstream->ostream.stream_errno = ret == 0 ? ESPIPE :
+ if ((ret = i_stream_get_size(instream, TRUE, &in_size)) < 0) {
+ outstream->ostream.stream_errno =
instream->stream_errno;
return -1;
}
+ /* if we couldn't find out the size, it means that instream
+ isn't a regular file_istream. we can be reasonably sure that
+ we can copy it safely the regular way. (there's really no
+ other possibility, other than failing completely.) */
+ }
+ if (ret > 0) {
i_assert(instream->v_offset <= in_size);
in_abs_offset = instream->real_stream->abs_start_offset +
More information about the dovecot-cvs
mailing list