[Suspend2][ 2/2] [Suspend2] Make cryptoapi deflate module handle full pages.

From: Nigel Cunningham
Date: Mon Jun 26 2006 - 12:50:35 EST


The cryptoapi deflate module currently returns an error when it
successfully handles a full page of data at the end of a compressed stream.
This patch addresses that behaviour.

Signed-off-by: Nigel Cunningham <nigel@xxxxxxxxxxxx>

crypto/deflate.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/crypto/deflate.c b/crypto/deflate.c
index f209368..2a38593 100644
--- a/crypto/deflate.c
+++ b/crypto/deflate.c
@@ -142,8 +142,15 @@ static int deflate_compress(void *ctx, c

ret = zlib_deflate(stream, Z_FINISH);
if (ret != Z_STREAM_END) {
- ret = -EINVAL;
- goto out;
+ if (!(ret == Z_OK && !stream->avail_in && !stream->avail_out)) {
+ ret = -EINVAL;
+ goto out;
+ } else {
+ u8 zerostuff = 0;
+ stream->next_out = &zerostuff;
+ stream->avail_out = 1;
+ ret = zlib_deflate(stream, Z_FINISH);
+ }
}
ret = 0;
*dlen = stream->total_out;

--
Nigel Cunningham nigel at suspend2 dot net
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/