You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We believe we've run into an issue where the msgpackr module can become "poisoned" after encoding a message longer than 2GiB.
Here's a test case that reproduces the issue on OS X Node.js v18.16.0. We've also encountered the issue on Linux Node.js v18.16.0.
constmsgpackr=require('msgpackr');constobj={};constlargeString='a'.repeat(0x100);constsize=2**30;// 1GiBconstnumberOfStringsRequiredFor1GB=Math.ceil(size/largeString.length);for(leti=0;i<numberOfStringsRequiredFor1GB;i++){constkey=i.toString();obj[key]=largeString;}// create a too-large target bufferconstpackr=newmsgpackr.Packr();// incidentally, this value will be encoded correctly, because Buffer.utf8Write// will only fail to write towards the beginning of the bufferconst_=packr.pack([obj,obj]);// now the packer module is poisonedconstnewPackr=newmsgpackr.Packr();// must be at least a 64ch string to trigger the bugconstmodestString='a'.repeat(64);constsimpleObj={name: modestString};constincorrectlyEncoded=newPackr.pack(simpleObj);constdecodedIncorrectlyEncoded=newPackr.unpack(incorrectlyEncoded);if(decodedIncorrectlyEncoded.name!==modestString){thrownewError("expected 64 'a's, but found ",decodedIncorrectlyEncoded.name);}
As a workaround, we're calling packr.useBuffer(Buffer.allocUnsafeSlow(8192)) to force the packr to reset its internal target buffer.
The text was updated successfully, but these errors were encountered:
Hi!
We believe we've run into an issue where the msgpackr module can become "poisoned" after encoding a message longer than 2GiB.
Here's a test case that reproduces the issue on OS X Node.js v18.16.0. We've also encountered the issue on Linux Node.js v18.16.0.
As a workaround, we're calling
packr.useBuffer(Buffer.allocUnsafeSlow(8192))
to force the packr to reset its internal target buffer.The text was updated successfully, but these errors were encountered: