Skip to content

Commit 0c6e73b

Browse files
Brandon Strubedsiper
authored andcommitted
gzip: 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. Signed-off-by: Brandon Strub <[email protected]>
1 parent 9a240b7 commit 0c6e73b

File tree

3 files changed

+455
-160
lines changed

3 files changed

+455
-160
lines changed

include/fluent-bit/flb_gzip.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,19 @@ int flb_gzip_compress(void *in_data, size_t in_len,
3131
int flb_gzip_uncompress(void *in_data, size_t in_len,
3232
void **out_data, size_t *out_size);
3333

34+
/*
35+
* Uncompress a gzip payload with trailing data. On success in_remaining is set to the number
36+
* of input bits not part of the first gzip payload.
37+
*/
38+
int flb_gzip_uncompress_multi(void *in_data, size_t in_len,
39+
void **out_data, size_t *out_size, size_t *in_remaining);
40+
3441
void *flb_gzip_decompression_context_create();
3542
void flb_gzip_decompression_context_destroy(void *context);
3643

3744
int flb_gzip_decompressor_dispatch(struct flb_decompression_context *context,
3845
void *out_data, size_t *out_size);
3946

4047
int flb_is_http_session_gzip_compressed(struct mk_http_session *session);
41-
size_t flb_gzip_count(const char *data, size_t len, size_t **out_borders, size_t border_count);
4248

4349
#endif

0 commit comments

Comments
 (0)