dovecot-1.1: bzip plugin: Seeking streams backwards was broken.
dovecot at dovecot.org
dovecot at dovecot.org
Wed Aug 27 19:21:23 EEST 2008
details: http://hg.dovecot.org/dovecot-1.1/rev/e024baa42a4f
changeset: 7834:e024baa42a4f
user: Timo Sirainen <tss at iki.fi>
date: Wed Aug 27 19:21:12 2008 +0300
description:
bzip plugin: Seeking streams backwards was broken.
diffstat:
1 file changed, 12 insertions(+)
src/plugins/zlib/istream-zlib.c | 12 ++++++++++++
diffs (30 lines):
diff -r 3fcfe8d316b6 -r e024baa42a4f src/plugins/zlib/istream-zlib.c
--- a/src/plugins/zlib/istream-zlib.c Wed Aug 27 10:13:29 2008 +0300
+++ b/src/plugins/zlib/istream-zlib.c Wed Aug 27 19:21:12 2008 +0300
@@ -18,6 +18,8 @@
/* Default maximum buffer size. Seeking backwards is very expensive, so keep
this pretty large */
#define DEFAULT_MAX_BUFFER_SIZE (1024*1024)
+
+#include <unistd.h>
struct zlib_istream {
struct istream_private istream;
@@ -124,7 +126,17 @@ i_stream_zlib_seek(struct istream_privat
#ifndef HAVE_GZSEEK
if (v_offset < start_offset) {
+ /* need to reopen, but since closing the file closes the
+ file descriptor we'll have to duplicate it first. */
+ int fd = dup(zstream->fd);
+ if (fd == -1) {
+ stream->istream.stream_errno = errno;
+ i_error("zlib istream: dup() failed: %m");
+ i_stream_close(&stream->istream);
+ return;
+ }
gzclose(zstream->file);
+ zstream->fd = fd;
zstream->file = gzdopen(zstream->fd, "r");
}
#else
More information about the dovecot-cvs
mailing list