- [PATCH 3/9] BUG/MEDIUM: Do not consider an agent check as failed on - [PATCH 4/9] BUG/MEDIUM: peers: correctly configure the client timeout - [PATCH 5/9] BUG/MEDIUM: buffer: one byte miss in buffer free space - [PATCH 6/9] BUG/MAJOR: http: don't read past buffer's end in - [PATCH 7/9] BUG/MEDIUM: http: the function "(req|res)-replace-value" - [PATCH 8/9] BUG/MINOR: compression: consider the expansion factor in - [PATCH 9/9] BUG/MEDIUM: http: hdr_cnt would not count any header when Signed-off-by: heil <heil@terminal-consulting.de>
43 lines
1.7 KiB
Diff
43 lines
1.7 KiB
Diff
From 9b9531d90dfd8a334958d23394afafd0185bfa21 Mon Sep 17 00:00:00 2001
|
|
From: Willy Tarreau <w@1wt.eu>
|
|
Date: Sat, 28 Mar 2015 12:20:33 +0100
|
|
Subject: [PATCH 8/9] BUG/MINOR: compression: consider the expansion factor in
|
|
init
|
|
|
|
When checking if the buffer is large enough, we used to rely on a fixed
|
|
size that was "apparently" enough. We need to consider the expansion
|
|
factor of deflate-encoded streams instead, which is of 5 bytes per 32kB.
|
|
The previous value was OK till 128kB buffers but became wrong past that.
|
|
It's totally harmless since we always keep the reserve when compressiong,
|
|
so there's 1kB or so available, which is enough for buffers as large as
|
|
6.5 MB, but better fix the check anyway.
|
|
|
|
This fix could be backported into 1.5 since compression was added there.
|
|
(cherry picked from commit 2aee2215c908c6997addcd1714b5b10f73c0703d)
|
|
---
|
|
src/compression.c | 9 ++++++---
|
|
1 file changed, 6 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/src/compression.c b/src/compression.c
|
|
index 3d6085e..d55f14e 100644
|
|
--- a/src/compression.c
|
|
+++ b/src/compression.c
|
|
@@ -130,9 +130,12 @@ int http_compression_buffer_init(struct session *s, struct buffer *in, struct bu
|
|
{
|
|
int left;
|
|
|
|
- /* not enough space */
|
|
- if (in->size - buffer_len(in) < 40)
|
|
- return -1;
|
|
+ /* output stream requires at least 10 bytes for the gzip header, plus
|
|
+ * at least 8 bytes for the gzip trailer (crc+len), plus a possible
|
|
+ * plus at most 5 bytes per 32kB block and 2 bytes to close the stream.
|
|
+ */
|
|
+ if (in->size - buffer_len(in) < 20 + 5 * ((in->i + 32767) >> 15))
|
|
+ return -1;
|
|
|
|
/* We start by copying the current buffer's pending outgoing data into
|
|
* a new temporary buffer that we initialize with a new empty chunk.
|
|
--
|
|
2.0.5
|
|
|