-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug in deflate with Z_FULL_FLUSH and a specific output buffer size #149
Comments
This is not a bug because zlib does not promise anywhere in the documentation that the output is invariant to changes in the amount of available output provided to the Despite that, I will look at how to remedy the situation and improve the predictability of flush results. The fault lies more in the definition of the interface than in the code. |
@madler I agree its a problem with the interface and not the code. However, consider this section of draft-ietf-hybi-permessage-compression-28:
https://tools.ietf.org/html/draft-ietf-hybi-permessage-compression-28#section-7.2.1 Turns out it is quite difficult to know when to remove the last flush marker without causing Another way to look at this is that a compression algorithm should produce a small as output as possible. If callers have no way to avoid spurious flush markers (I have not been able to figure out how to detect that a flush marker is spurious), I would consider that a bug. |
Actually it's quite easy to do if you separate the compression from the flushing. Just call |
Ah!!!! Thanks a zillion! I was wondering about that but sometimes its really tough to decipher the description of the flush parameters in the documentation. |
* Fix build problems about NEON on AArch64 NEON is enabled by default on armv8-a platforms, and so NEON related objects should be included when the platform is armv8-a. Errors about adler32_neon will occur when you run ./configure on armv8-a platforms without --neon option, because zlib-ng uses --neon option to include NEON related objects regardless of Arm architecture. You will have similar issue when you build the project with cmake. This patch fixes the problem by including NEON related objects when the platform is armv8-a(including aarch64). Use adler32_neon only when zlib-ng is configured with --neon (or -DWITH_NEON=ON if using cmake), or else use the default adler32 no matter what Arm architecture is. Signed-off-by: Richael Zhuang <richael.zhuang@arm.com>
When
deflate
is called with a buffer that is exactly large enough to hold the output,avail_out
comes back as zero. As per the ZLib documentation:If deflate returns Z_OK and with zero avail_out, it must be called again after making room in the output buffer because there might be more output pending.
Note that in this case, the sync trailer has already been emitted (0x00, 0x00, 0xff, 0xff). On the subsequent call to
deflate
, a second sync trailer is emitted. This results in an unnecessary 4 bytes being added to the output.This example program illustrates the problem. The result of compress should be the same no matter the value of
availOut
. But it isn't, the first string is 24 bytes in size and the second string is 19 bytes in size even though both inflate to the same result.The text was updated successfully, but these errors were encountered: