| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Can you add a test? |
Sorry, something went wrong.
There was a problem hiding this comment.
Could you do something more like:
err = null;
try {
buf = Buffer.concat(buffers, nread);
} catch (e) {
err = e;
}
buffers = [];
engine.close();
callback(err, buf);
Sorry, something went wrong.
There was a problem hiding this comment.
done
Sorry, something went wrong.
|
Do you mean test that the error is correctly caught ? |
Sorry, something went wrong.
|
There is an upcoming Buffer rewrite that, if I understand correctly, will get rid of the upper limit anyway. @trevnorris, do you have any thoughts for a test here? |
Sorry, something went wrong.
|
The check should be there. But if we're confident that nread is the length of all buffers then only need to check it against kMaxLength, and return an error if greater than. No need for the try catch. |
Sorry, something went wrong.
|
@trevnorris Good point, I made that change. Also added a check in the sync code to generate the same error. |
Sorry, something went wrong.
|
True. And that may be a problem on ARM devices. @rvagg Thoughts? |
Sorry, something went wrong.
|
yeah, that's not going to be a happy time on the small devices, if it must be tested I guess you might want to first test for the amount of system memory available, but that's also going to be tricky for cross-platform support, the alternative is to just skip it if arch == arm, but there's also mips (tessel) and Windows 10 on rpi and Atom and ... |
Sorry, something went wrong.
|
My vote would be to make an internal module (lib/internal/smalloc, for the sake of argument) that exposes getMaxLength() & override it in the test to return a much smaller value. |
Sorry, something went wrong.
|
that may be possible by process.binding('smalloc').kMaxLength = <some small value> before requiring zlib. problem is that may have other unknown consequences. |
Sorry, something went wrong.
|
@trevnorris your proposal is working, thanks! I added a test. |
Sorry, something went wrong.
|
One more addition to the test. Can you set it back to the original value of 0x3FFFFFFF after requiring zlib? After that let's add this to CI and see how it holds up. |
Sorry, something went wrong.
|
Done. Can somebody start a CI? |
Sorry, something went wrong.
Sorry, something went wrong.
|
All green! LGTY ? |
Sorry, something went wrong.
|
LGTM @indutny have any objections to this change? |
Sorry, something went wrong.
|
LGTM! It does look like a security concern to me. I think we may want to issue a CVE. What are your thoughts on this? |
Sorry, something went wrong.
|
I believe the only issue is that a client could forcefully crash a server. That's not a trivial issue by any means. I'm just not sure if it classifies as security vulnerability or not. If you think it is then cool. Let's do a CVE. |
Sorry, something went wrong.
|
Yeah, but it is a bit trivial do so (see the test). Anyway, how should we fill a CVE cc @nodejs/tsc |
Sorry, something went wrong.
|
Yup. Let's save that for the next one. This one has already been signed off. :-) |
Sorry, something went wrong.
|
ping @trevnorris : can this be landed ? |
Sorry, something went wrong.
|
@targos I'm not sure if this should land before the CVE is created. If @indutny doesn't respond by the TSC meeting on Wednesday then I'll bring it up in the meeting. i.e. Your patch is great. The hold up is missing process around landing a patch that should have a CVE. |
Sorry, something went wrong.
|
Great work all, definitely should have a CVE. |
Sorry, something went wrong.
|
I think we should land it anyway, there is no point in releasing stuff without this ;) I don't have any further comments since I wasn't ever involved in the process of filing CVE. cc @piscisaureus |
Sorry, something went wrong.
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: #1811 Reviewed-By: Fedor Indutny <fedor@indutny.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
|
Landed in 3806d87. Thanks for the patch. |
Sorry, something went wrong.
|
@indutny @trevnorris @nodejs/tsc If I understand correctly, this issue also exists in node v0.10.x and node v0.12.x, so before issuing a CVE, I would suggest getting ready to backport and release the changes in this PR into those branches. Is that something you could help with? |
Sorry, something went wrong.
|
Created nodejs/node-v0.x-archive#25536 to track that. |
Sorry, something went wrong.
|
@misterdjules The fix itself is straight forward, but currently the way to test uses properties on the smalloc module. Not sure how this could be tested on v0.10 without needing to use 1GB of memory. |
Sorry, something went wrong.
PR-URL: #1996 Notable changes * module: The number of syscalls made during a require() have been significantly reduced again (see #1801 from v2.2.0 for previous work), which should lead to a performance improvement (Pierre Inglebert) #1920. * npm: - Upgrade to v2.11.2 (Rebecca Turner) #1956. - Upgrade to v2.11.3 (Forrest L Norvell) #2018. * zlib: A bug was discovered where the process would abort if the final part of a zlib decompression results in a buffer that would exceed the maximum length of 0x3fffffff bytes (~1GiB). This was likely to only occur during buffered decompression (rather than streaming). This is now fixed and will instead result in a thrown RangeError (Michaël Zasso) #1811.
PR-URL: #1996 Notable changes * module: The number of syscalls made during a require() have been significantly reduced again (see #1801 from v2.2.0 for previous work), which should lead to a performance improvement (Pierre Inglebert) #1920. * npm: - Upgrade to v2.11.2 (Rebecca Turner) #1956. - Upgrade to v2.11.3 (Forrest L Norvell) #2018. * zlib: A bug was discovered where the process would abort if the final part of a zlib decompression results in a buffer that would exceed the maximum length of 0x3fffffff bytes (~1GiB). This was likely to only occur during buffered decompression (rather than streaming). This is now fixed and will instead result in a thrown RangeError (Michaël Zasso) #1811.
| Back | FazBrowse Home | New Git URL |
If the final buffer needs to be larger than kMaxLength, the concatenation fails and there is no way to catch the error:
buffer.js:173 throw new RangeError('Attempt to allocate Buffer larger than maximum ' + ^ RangeError: Attempt to allocate Buffer larger than maximum size: 0x3fffffff bytes at checked (buffer.js:173:11) at fromNumber (buffer.js:56:51) at new Buffer (buffer.js:41:5) at Function.Buffer.concat (buffer.js:263:16) at Gunzip.onEnd (zlib.js:212:22) at emitNone (events.js:72:20) at Gunzip.emit (events.js:163:7) at endReadableNT (_stream_readable.js:890:12) at doNTCallback2 (node.js:437:9) at process._tickCallback (node.js:351:17)Testcase : https://gist.github.com/targos/643a802e0ed4fa60f3bd