summaryrefslogtreecommitdiff
path: root/lib/zlib.js
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-02-28 22:25:59 +0100
committerRuben Bridgewater <ruben@bridgewater.de>2019-03-04 00:13:40 +0100
commit28db96f31c2724b16d6b9bec19c600023365b7cc (patch)
treee81006bc403df7ee0cf23b05a73eb0a647db95c2 /lib/zlib.js
parenta0778a97e19fb6e661a4277f18f758443d20470c (diff)
downloadandroid-node-v8-28db96f31c2724b16d6b9bec19c600023365b7cc.tar.gz
android-node-v8-28db96f31c2724b16d6b9bec19c600023365b7cc.tar.bz2
android-node-v8-28db96f31c2724b16d6b9bec19c600023365b7cc.zip
zlib: report premature ends earlier
Report end-of-stream when decompressing when we detect it, and do not wait until the writable side of a zlib stream is closed as well. Refs: https://github.com/nodejs/node/issues/26332 PR-URL: https://github.com/nodejs/node/pull/26363 Refs: https://github.com/nodejs/node/issues/26332 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/zlib.js')
-rw-r--r--lib/zlib.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/zlib.js b/lib/zlib.js
index b267fda4ea..5e49ba40db 100644
--- a/lib/zlib.js
+++ b/lib/zlib.js
@@ -546,6 +546,16 @@ function processCallback() {
return;
}
+ if (availInAfter > 0) {
+ // If we have more input that should be written, but we also have output
+ // space available, that means that the compression library was not
+ // interested in receiving more data, and in particular that the input
+ // stream has ended early.
+ // This applies to streams where we don't check data past the end of
+ // what was consumed; that is, everything except Gunzip/Unzip.
+ self.push(null);
+ }
+
// finished with the chunk.
this.buffer = null;
this.cb();