aboutsummaryrefslogtreecommitdiff
path: root/sys/opencrypto
diff options
context:
space:
mode:
authorBjoern A. Zeeb <bz@FreeBSD.org>2009-11-28 17:44:57 +0000
committerBjoern A. Zeeb <bz@FreeBSD.org>2009-11-28 17:44:57 +0000
commit9699afb61b4e61de5c0089e6548e137f04c1ace6 (patch)
treea8fd57fcffa6d6aa665211571f210935cddb6fc4 /sys/opencrypto
parent227f66048ee60b65d4683e77d9746c7c6b89cf44 (diff)
Notes
Diffstat (limited to 'sys/opencrypto')
-rw-r--r--sys/opencrypto/deflate.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/sys/opencrypto/deflate.c b/sys/opencrypto/deflate.c
index 239435e06fa4..852b66aa26de 100644
--- a/sys/opencrypto/deflate.c
+++ b/sys/opencrypto/deflate.c
@@ -138,8 +138,8 @@ deflate_global(data, size, decomp, out)
goto bad;
}
for (;;) {
- error = decomp ? inflate(&zbuf, Z_PARTIAL_FLUSH) :
- deflate(&zbuf, Z_PARTIAL_FLUSH);
+ error = decomp ? inflate(&zbuf, Z_SYNC_FLUSH) :
+ deflate(&zbuf, Z_FINISH);
if (error != Z_OK && error != Z_STREAM_END) {
/*
* Unfortunately we are limited to 5 arguments,
@@ -153,9 +153,13 @@ deflate_global(data, size, decomp, out)
zbuf.state->dummy, zbuf.total_out);
goto bad;
}
- else if (zbuf.avail_in == 0 && zbuf.avail_out != 0)
- goto end;
- else if (zbuf.avail_out == 0 && i < (ZBUF - 1)) {
+ if (decomp && zbuf.avail_in == 0 && error == Z_STREAM_END) {
+ /* Done. */
+ break;
+ } else if (!decomp && error == Z_STREAM_END) {
+ /* Done. */
+ break;
+ } else if (zbuf.avail_out == 0) {
/* we need more output space, allocate size */
buf[i].out = malloc((u_long) size,
M_CRYPTO_DATA, M_NOWAIT);
@@ -170,6 +174,7 @@ deflate_global(data, size, decomp, out)
zbuf.avail_out = buf[i].size;
i++;
} else {
+ /* Unexpect result. */
/*
* Unfortunately we are limited to 5 arguments,
* thus, again, use two probes.
@@ -184,7 +189,6 @@ deflate_global(data, size, decomp, out)
}
}
-end:
result = count = zbuf.total_out;
*out = malloc((u_long) result, M_CRYPTO_DATA, M_NOWAIT);