mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2024-11-15 03:14:56 -05:00
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:
parent
9778bb920b
commit
571d0e0c25
1 changed files with 11 additions and 1 deletions
|
@ -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()
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue