mirror of https://github.com/lukechilds/node.git
Browse Source
If the accumulation of data for the final Buffer is greater than kMaxLength it will throw an un-catchable RangeError. Instead now pass the generated error to the callback. PR-URL: https://github.com/nodejs/io.js/pull/1811 Reviewed-By: Fedor Indutny <fedor@indutny.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>v2.3.1-release
committed by
Trevor Norris
2 changed files with 40 additions and 2 deletions
@ -0,0 +1,22 @@ |
|||
'use strict'; |
|||
|
|||
const assert = require('assert'); |
|||
|
|||
// Change kMaxLength for zlib to trigger the error
|
|||
// without having to allocate 1GB of buffers
|
|||
const smalloc = process.binding('smalloc'); |
|||
smalloc.kMaxLength = 128; |
|||
const zlib = require('zlib'); |
|||
smalloc.kMaxLength = 0x3fffffff; |
|||
|
|||
const encoded = new Buffer('H4sIAAAAAAAAA0tMHFgAAIw2K/GAAAAA', 'base64'); |
|||
|
|||
// Async
|
|||
zlib.gunzip(encoded, function(err) { |
|||
assert.ok(err instanceof RangeError); |
|||
}); |
|||
|
|||
// Sync
|
|||
assert.throws(function() { |
|||
zlib.gunzipSync(encoded); |
|||
}, RangeError); |
Loading…
Reference in new issue