From d8aa10f515eb3ff2741d2db646480862e8cb9dfa Mon Sep 17 00:00:00 2001
From: Michal Hlavinka <mhlavink@redhat.com>
Date: Mon, 9 Jul 2018 14:03:21 +0200
Subject: [PATCH] add compression test suite assert crash fix

---
 ...464385bbcd763f90abc5e212c569b9279ffa.patch | 41 +++++++++++++++++++
 dovecot.spec                                  |  4 ++
 2 files changed, 45 insertions(+)
 create mode 100644 64f4464385bbcd763f90abc5e212c569b9279ffa.patch

diff --git a/64f4464385bbcd763f90abc5e212c569b9279ffa.patch b/64f4464385bbcd763f90abc5e212c569b9279ffa.patch
new file mode 100644
index 0000000..e846809
--- /dev/null
+++ b/64f4464385bbcd763f90abc5e212c569b9279ffa.patch
@@ -0,0 +1,41 @@
+From 64f4464385bbcd763f90abc5e212c569b9279ffa Mon Sep 17 00:00:00 2001
+From: Paul Howarth <paul@city-fan.org>
+Date: Mon, 2 Jul 2018 11:52:14 +0100
+Subject: [PATCH] lib-compression: Fix assert-crash in test suite on 32bit
+ systems
+
+Fix compilation warnings in test-compression.c due to mismatches
+between size_t and uoff_t, which then manifests in assert-crashes
+running the test suite on 32bit systems.
+---
+ src/lib-compression/test-compression.c | 9 +++++----
+ 1 file changed, 5 insertions(+), 4 deletions(-)
+
+diff --git a/src/lib-compression/test-compression.c b/src/lib-compression/test-compression.c
+index 0f7df3d1fe..f62d7d6094 100644
+--- a/src/lib-compression/test-compression.c
++++ b/src/lib-compression/test-compression.c
+@@ -20,6 +20,7 @@ static void test_compression_handler(const struct compression_handler *handler)
+ 	unsigned char buf[IO_BLOCK_SIZE];
+ 	const unsigned char *data;
+ 	size_t size;
++	uoff_t stream_size;
+ 	struct sha1_ctxt sha1;
+ 	unsigned char output_sha1[SHA1_RESULTLEN], input_sha1[SHA1_RESULTLEN];
+ 	unsigned int i;
+@@ -73,11 +74,11 @@ static void test_compression_handler(const struct compression_handler *handler)
+ 	file_input = i_stream_create_fd(fd, IO_BLOCK_SIZE);
+ 	input = handler->create_istream(file_input, FALSE);
+ 
+-	test_assert(i_stream_get_size(input, FALSE, &size) == 1);
+-	test_assert(size == compressed_size);
++	test_assert(i_stream_get_size(input, FALSE, &stream_size) == 1);
++	test_assert(stream_size == compressed_size);
+ 
+-	test_assert(i_stream_get_size(input, TRUE, &size) == 1);
+-	test_assert(size == uncompressed_size);
++	test_assert(i_stream_get_size(input, TRUE, &stream_size) == 1);
++	test_assert(stream_size == uncompressed_size);
+ 
+ 	sha1_init(&sha1);
+ 	for (bool seeked = FALSE;;) {
diff --git a/dovecot.spec b/dovecot.spec
index 33a49af..bdb377c 100644
--- a/dovecot.spec
+++ b/dovecot.spec
@@ -34,6 +34,9 @@ Patch8: dovecot-2.2.20-initbysystemd.patch
 Patch9: dovecot-2.2.22-systemd_w_protectsystem.patch
 Patch10: dovecot-2.3.0.1-libxcrypt.patch
 
+# for dovecot <= 2.3.2
+Patch11: 64f4464385bbcd763f90abc5e212c569b9279ffa.patch
+
 Source15: prestartscript
 
 BuildRequires: gcc, gcc-c++, openssl-devel, pam-devel, zlib-devel, bzip2-devel, libcap-devel
@@ -135,6 +138,7 @@ This package provides the development files for dovecot.
 %patch8 -p1 -b .initbysystemd
 %patch9 -p1 -b .systemd_w_protectsystem
 %patch10 -p1 -b .libxcrypt
+%patch11 -p1 -b .64f4464385bbcd763f90abc5e212c569b9279ffa
 
 #pushd dovecot-2*3-pigeonhole-%{pigeonholever}
 #popd