changeset 2985:f1e67917a669 HEAD

o_stream_send_istream() was broken and could have just caused copying to be done infinitely filling up disk.
author Timo Sirainen <tss@iki.fi>
date Thu, 16 Dec 2004 22:41:15 +0200
parents 3fb1808e7bff
children 51a05fd00324
files src/lib/ostream-file.c
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/ostream-file.c	Thu Dec 16 03:41:25 2004 +0200
+++ b/src/lib/ostream-file.c	Thu Dec 16 22:41:15 2004 +0200
@@ -541,8 +541,17 @@
 			}
 		}
 		outstream->ostream.offset += ret;
-		i_stream_skip(instream, ret - (pos == 1 ? 0 : iov[0].iov_len));
 
+		/* only the last iov is from input stream. skip others. */
+		for (pos = 0; pos < iov_len-1; pos++) {
+			if ((size_t)ret < iov[pos].iov_len)
+				break;
+			ret -= iov[pos].iov_len;
+		}
+		if (pos != iov_len-1)
+			break;
+
+		i_stream_skip(instream, ret);
 		if ((size_t)ret != iov[pos].iov_len)
 			break;