ret = safe_sendfile(foutstream->fd, in_fd, &offset,
MAX_SSIZE_T(send_size));
if (ret <= 0) {
- if (ret == 0)
- break;
+ if (ret == 0) {
+ /* Unexpectedly early EOF at input */
+ i_stream_seek(instream, v_offset);
+ instream->eof = TRUE;
+ *res_r = OSTREAM_SEND_ISTREAM_RESULT_FINISHED;
+ return TRUE;
+ }
if (foutstream->file) {
if (errno == EINTR) {
/* automatically retry */
test_assert(read(sock_fd[1], buf, sizeof(buf)) == 4 &&
memcmp(buf, "defg", 4) == 0);
i_stream_unref(&input2);
- i_stream_unref(&input);
+ /* test reading past EOF */
+ i_stream_seek(input, 0);
+ input2 = i_stream_create_limit(input, 20);
+ test_assert(o_stream_send_istream(output, input2) == OSTREAM_SEND_ISTREAM_RESULT_FINISHED);
+ test_assert(input2->v_offset == 10);
+ test_assert(output->offset == 14);
+ i_stream_unref(&input2);
+
+ i_stream_unref(&input);
o_stream_destroy(&output);
i_close_fd(&sock_fd[1]);