gzip: in_forward: Fix concatenated gzip payloads gzip concatenated - #10259
Merged
edsiper merged 2 commits intoMay 8, 2025
Merged
Conversation
Tangui0232
requested review from
edsiper,
fujimotos,
koleini and
leonardo-albertovich
as code owners
April 26, 2025 00:31
Tangui0232
force-pushed
the
fix-concatenated-gzip-payloads-gzip-concatenated
branch
from
April 29, 2025 00:31
39ced5c to
6bb63a5
Compare
Author
|
I fixed the windows and centos7 build issues and separated the commit into two commits based on my reading of https://github.com/fluent/fluent-bit/blob/master/CONTRIBUTING.md#commit-changes. |
cosmo0920
reviewed
Apr 30, 2025
Contributor
|
This commit 6bb63a5 does not have Signed-off line. So, we need to mark there. |
Tangui0232
force-pushed
the
fix-concatenated-gzip-payloads-gzip-concatenated
branch
from
April 30, 2025 23:39
f5e9580 to
6ed4a01
Compare
Member
|
@cosmo0920 it seems the DCO is fixed now, would you please validate the forward/zip compat side ? |
cosmo0920
requested changes
May 7, 2025
cosmo0920
left a comment
Contributor
There was a problem hiding this comment.
I commented minor style issues.
I confirmed that this PR works against our internal reproducible.
Thanks for fixing this long standing issue. 😄
Tangui0232
force-pushed
the
fix-concatenated-gzip-payloads-gzip-concatenated
branch
3 times, most recently
from
May 8, 2025 03:38
317aa3e to
15d6e47
Compare
added 2 commits
May 7, 2025 22:40
The implementation of flb_gzip_count is flawed as it relies on looking for valid gzip headers. A gzip payload can be generated that includes a valid gzip header in the gzip body - see test_header_in_gzip_body. Removed flb_gzip_count and associated handling in favor of utilizing mz_inflate to find the boundaries between concatenated gzip payloads during decompression. mz_inflate will stop when it reaches the end of the gzip body and mz_stream.in_avail contains the bytes left in the buffer for processing. Signed-off-by: Brandon Strub <brandon.strub@veritas.com>
Utilize new flb_gzip_uncompress_multi method to support concatenated gzip payloads. Signed-off-by: Brandon Strub <brandon.strub@veritas.com>
Tangui0232
force-pushed
the
fix-concatenated-gzip-payloads-gzip-concatenated
branch
from
May 8, 2025 03:40
15d6e47 to
44ef24f
Compare
cosmo0920
approved these changes
May 8, 2025
cosmo0920
left a comment
Contributor
There was a problem hiding this comment.
Looks good. Thanks for addressing style issues.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix concatenated gzip payload handling.
The implementation of flb_gzip_count is flawed as it relies on looking
for valid gzip headers. A gzip payload can be generated that includes
a valid gzip header in the gzip body - see test_header_in_gzip_body.
Removed flb_gzip_count and associated handling in favor of utilizing
mz_inflate to find the boundaries between concatenated gzip payloads
during decompression. mz_inflate will stop when it reaches the end of
the gzip body and mz_stream.in_avail contains the bytes left in the
buffer for processing.
With this change we are no longer able to allocate the exact memory
required by reading the decompressed length out of the gzip footer
(since we don't know where it is). Instead we allocate buffers of size
FLB_GZIP_BUFFER_SIZE (1MB) as an intermediate location to put the
decompressed data and use MZ_SYNC_FLUSH instead of MZ_FINISH
when reading to allow mz_inflate to return back to us when it needs
more buffer space. In the case of requiring more space we allocate
another buffer (up to FLB_GZIP_MAX_BUFFERS (100)) and call
mz_inflate again. Once complete we allocate the final buffer and copy
the data from the buffers in. This means that we use at least twice the
amount of memory as before for the short period where we are
copying the data from the intermediate buffers to the final buffer.
Addresses #9058.
Enter
[N/A]in the box, if an item is not applicable to your change.Testing
Before we can approve your change; please submit the following in a comment:
Forward output plugin side:
Forward input plugin side:
fluentbit_debug_output.txt
run_code_analysis_output.txt
I tried running valgrind in an actual running environment as well, but nearly all TLS communication failed. I can look into this more if required.
If this is a change to packaging of containers or native binaries then please confirm it works for all targets.
ok-package-testlabel to test for all targets (requires maintainer to do).Documentation
Backporting
Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.