This repository has been archived by the owner on Oct 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stream: fix highWaterMark integer overflow
Fixes integer overflows when supplying values exceeding MAX_SAFE_INTEGER for highWaterMark. PR-URL: nodejs/node#12593 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Luca Maraschi <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
- Loading branch information
Showing
3 changed files
with
20 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict'; | ||
require('../common'); | ||
|
||
// This test ensures that the stream implementation correctly handles values | ||
// for highWaterMark which exceed the range of signed 32 bit integers. | ||
|
||
const assert = require('assert'); | ||
const stream = require('stream'); | ||
|
||
// This number exceeds the range of 32 bit integer arithmetic but should still | ||
// be handled correctly. | ||
const ovfl = Number.MAX_SAFE_INTEGER; | ||
|
||
const readable = stream.Readable({ highWaterMark: ovfl }); | ||
assert.strictEqual(readable._readableState.highWaterMark, ovfl); | ||
|
||
const writable = stream.Writable({ highWaterMark: ovfl }); | ||
assert.strictEqual(writable._writableState.highWaterMark, ovfl); |