]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: istream-file: Fixed o_stream_send_istream()
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 18 May 2016 16:22:40 +0000 (19:22 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 18 May 2016 16:22:40 +0000 (19:22 +0300)
src/lib/ostream-file.c

index dc157cbd652edcc9ec5a03ba64e521a00ca66cf1..c026868b7ac874dd869769c73a676851911b3bb6 100644 (file)
@@ -714,7 +714,7 @@ static int io_stream_sendfile(struct ostream_private *outstream,
                return -1;
 
         v_offset = instream->v_offset;
-       for (;;) {
+       while (v_offset < in_size) {
                offset = instream->real_stream->abs_start_offset + v_offset;
                send_size = in_size - v_offset;
 
@@ -754,7 +754,12 @@ static int io_stream_sendfile(struct ostream_private *outstream,
        }
 
        i_stream_seek(instream, v_offset);
-       return ret <= 0 ? ret : 1;
+       if (v_offset == in_size) {
+               instream->eof = TRUE;
+               return 1;
+       }
+       i_assert(ret <= 0);
+       return ret;
 }
 
 static int io_stream_copy_backwards(struct ostream_private *outstream,