more decompression more reliable : ignore packet that cannot be decompressed

do print an error though, because servers should not send wrong packets

mitigate #462
This commit is contained in:
Romain Beaumont 2018-05-20 02:50:26 +02:00
parent 9778bb920b
commit 571d0e0c25
No known key found for this signature in database
GPG key ID: DB60E388B3BCF286

View file

@ -52,7 +52,17 @@ class Decompressor extends Transform {
return cb()
} else {
zlib.inflate(chunk.slice(size), (err, newBuf) => {
if (err) { return cb(err) }
if (err) {
console.error('problem inflating chunk')
console.error('uncompressed length ' + value)
console.error('compressed length ' + chunk.length)
console.error('hex ' + chunk.toString('hex'))
console.log(err)
return cb()
}
if (newBuf.length !== value) {
console.error('uncompressed length should be ' + value + ' but is ' + newBuf.length)
}
this.push(newBuf)
return cb()
})