summaryrefslogtreecommitdiffstats
path: root/github704.patch
diff options
context:
space:
mode:
authorRemi Collet <remi@remirepo.net>2024-04-17 11:52:58 +0200
committerRemi Collet <remi@php.net>2024-04-17 11:52:58 +0200
commitc5459c92a82c33611ab69637f75c47d4b0045a6f (patch)
treeafcff7d2bcf66050d22e126b7b76a39030396152 /github704.patch
parent3bdba2f0ae51baf2596a2dd5c7ce756bc560147c (diff)
add upstream patch for zlib-ng
Diffstat (limited to 'github704.patch')
-rw-r--r--github704.patch76
1 files changed, 76 insertions, 0 deletions
diff --git a/github704.patch b/github704.patch
new file mode 100644
index 0000000..22e894a
--- /dev/null
+++ b/github704.patch
@@ -0,0 +1,76 @@
+# HG changeset patch
+# User Dmitry Volyntsev <xeioex@nginx.com>
+# Date 1713338720 25200
+# Wed Apr 17 00:25:20 2024 -0700
+# Node ID ca18b6292d6eea0bb58f5e7b08a7249d04629a8a
+# Parent 40c980ca34563c056e871d5585d1aedd8f4d0890
+Zlib: fixed inflate().
+
+Previously, the function might fail to return the last part of the
+compressed content. This problem is more visible when output size is >
+1024 or when chunkSize < the content size.
+
+diff --git a/external/njs_zlib_module.c b/external/njs_zlib_module.c
+--- a/external/njs_zlib_module.c
++++ b/external/njs_zlib_module.c
+@@ -463,7 +463,7 @@ njs_zlib_ext_inflate(njs_vm_t *vm, njs_v
+
+ njs_chb_init(&chain, njs_vm_memory_pool(vm));
+
+- while (stream.avail_in > 0) {
++ while (rc != Z_STREAM_END) {
+ stream.next_out = njs_chb_reserve(&chain, chunk_size);
+ if (njs_slow_path(stream.next_out == NULL)) {
+ njs_vm_memory_error(vm);
+diff --git a/src/test/njs_unit_test.c b/src/test/njs_unit_test.c
+--- a/src/test/njs_unit_test.c
++++ b/src/test/njs_unit_test.c
+@@ -22352,6 +22352,13 @@ static njs_unit_test_t njs_zlib_test[]
+ njs_str("eJwLd/R2BAAC+gEl,eJw7t/HcpnObAQ/sBIE=") },
+
+ { njs_str("const zlib = require('zlib');"
++ "const buf = 'αβγ'.repeat(56);"
++ "const enc = zlib.deflateRawSync(buf, {chunkSize:64}).toString('base64');"
++ "const dec = zlib.inflateRawSync(Buffer.from(enc, 'base64')).toString();"
++ "buf == dec"),
++ njs_str("true") },
++
++ { njs_str("const zlib = require('zlib');"
+ "['WAKA'.repeat(1024), 'αβγ'.repeat(1024)]"
+ ".map(v => [v, zlib.deflateRawSync(v).toString('base64')])"
+ ".every(pair => pair[0] == zlib.inflateRawSync(Buffer.from(pair[1], 'base64')).toString())"),
+# HG changeset patch
+# User Dmitry Volyntsev <xeioex@nginx.com>
+# Date 1713338872 25200
+# Wed Apr 17 00:27:52 2024 -0700
+# Node ID 2b6b25100aef6cbf8c2ab0bc2bd4d60942e41a45
+# Parent ca18b6292d6eea0bb58f5e7b08a7249d04629a8a
+Zlib: improved tests with zlib-ng.
+
+This fixes #704 issue on Github.
+
+diff --git a/src/test/njs_unit_test.c b/src/test/njs_unit_test.c
+--- a/src/test/njs_unit_test.c
++++ b/src/test/njs_unit_test.c
+@@ -22319,14 +22319,15 @@ static njs_unit_test_t njs_zlib_test[]
+ njs_str("WAKA,αβγ") },
+
+ { njs_str("const zlib = require('zlib');"
+- "['WAKA', 'αβγ']"
+- ".map(v => zlib.deflateRawSync(v).toString('base64'))"),
+- njs_str("C3f0dgQA,O7fx3KZzmwE=") },
++ "const enc = ['WAKA', 'αβγ'].map(v => zlib.deflateRawSync(v).toString('base64'));"
++ "enc.map(v => zlib.inflateRawSync(Buffer.from(v, 'base64')).toString())"),
++ njs_str("WAKA,αβγ") },
+
+ { njs_str("const zlib = require('zlib');"
+- "['WAKA', 'αβγ']"
+- ".map(v => zlib.deflateRawSync(v, {dictionary: Buffer.from('WAKA')}).toString('base64'))"),
+- njs_str("CwdiAA==,O7fx3KZzmwE=") },
++ "const enc = ['WAKA', 'αβγ']"
++ ".map(v => zlib.deflateRawSync(v, {dictionary: Buffer.from('WAKA')}).toString('base64'));"
++ "enc.map(v => zlib.inflateRawSync(Buffer.from(v, 'base64'), {dictionary: Buffer.from('WAKA')}))"),
++ njs_str("WAKA,αβγ") },
+
+ { njs_str("const zlib = require('zlib');"
+ "['WAKA', 'αβγ']"