Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buffer.writeInt32LE() does throws value of out range error #29041

Closed
imaynotbereal opened this issue Aug 8, 2019 · 5 comments
Closed

Buffer.writeInt32LE() does throws value of out range error #29041

imaynotbereal opened this issue Aug 8, 2019 · 5 comments

Comments

@imaynotbereal
Copy link

  • Version: 12.8.0
  • Platform: Windows 10 64-bit
  • Subsystem: Buffer

I am using protractor for testing AngularJS based web application. I recently upgraded node from v6.9.2 to V12.8.0 and I am experiencing issue while calling protractor's ElementFinder.sendKeys().
I managed to create below snippet to reproduce the issue:

D:\gTools\node\node-v12.8.0-win-x86>node
Welcome to Node.js v12.8.0.
Type ".help" for more information.
> var data = new Buffer(70);
undefined
> (node:13384) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
data.writeUInt32LE(33639248);
4
> data.writeUInt16LE(10, 4);
6
> data.writeUInt16LE(10, 6);
8
> data.writeUInt16LE(0, 8);
10
> data.writeUInt16LE(0, 10);
12
> data.writeUInt32LE(1325687893, 12);
16
> data.writeInt32LE(2728251391, 16, true);
Thrown:
RangeError [ERR_OUT_OF_RANGE]: The value of "value" is out of range. It must be >= -2147483648 and <= 2147483647. Received 2728251391
    at checkInt (internal/buffer.js:58:11)
    at writeU_Int32LE (internal/buffer.js:678:3)
    at Buffer.writeInt32LE (internal/buffer.js:847:10)
    at repl:1:6
    at Script.runInThisContext (vm.js:126:20)
    at REPLServer.defaultEval (repl.js:384:29)
    at bound (domain.js:420:14)
    at REPLServer.runBound [as eval] (domain.js:433:12)
    at REPLServer.onLine (repl.js:700:10)
    at REPLServer.emit (events.js:208:15)

However when the same code is executed on Node 6.9.2, it works fine.

C:\Users\pvaddepa>node -v
v6.9.5

C:\Users\pvaddepa>D:

D:\tools\node>node
> let b = new Buffer(70);
undefined
> b.writeInt32LE(0xA29DCFFF);
TypeError: "value" argument is out of bounds
    at checkInt (buffer.js:1027:11)
    at Buffer.writeInt32LE (buffer.js:1217:5)
    at repl:1:3
    at sigintHandlersWrap (vm.js:22:35)
    at sigintHandlersWrap (vm.js:96:12)
    at ContextifyScript.Script.runInThisContext (vm.js:21:12)
    at REPLServer.defaultEval (repl.js:346:29)
    at bound (domain.js:280:14)
    at REPLServer.runBound [as eval] (domain.js:293:12)
    at REPLServer.<anonymous> (repl.js:545:10)
> var data = new Buffer(70);
undefined
> data.writeUInt32LE(33639248);
4
> data.writeUInt16LE(10, 4);
6
> data.writeUInt16LE(10, 6);
8
> data.writeUInt16LE(0, 8);
10
> data.writeUInt16LE(0, 10);
12
> data.writeUInt32LE(1325687893, 12);
16
> data.writeInt32LE(2728251391, 16, true);
20

The same issue is found on node V10.15.3 and on
Linux machine: Linux dory 4.1.12-124.28.1.el7uek.x86_64 #2 SMP Mon Jun 3 14:09:53 PDT 2019 x86_64 x86_64 x86_64 GNU/Linux

@mscdex
Copy link
Contributor

mscdex commented Aug 8, 2019

The noAssert option was removed starting with node v10.0.0.

@mscdex mscdex closed this as completed Aug 8, 2019
@imaynotbereal
Copy link
Author

imaynotbereal commented Aug 8, 2019

@mscdex If I call writeInt32LE() even without noAssert I still see the same error:

D:\gTools\node\node-v12.8.0-win-x86>node.exe
Welcome to Node.js v12.8.0.
Type ".help" for more information.
> var data = new Buffer(70);
undefined
> (node:3472) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
data.writeUInt32LE(33639248);
4
> data.writeUInt16LE(10, 4);
6
> data.writeUInt16LE(10, 6);
8
> data.writeUInt16LE(0, 8);
10
> data.writeUInt16LE(0, 10);
12
> data.writeUInt32LE(1325687893, 12);
16
> data.writeInt32LE(2728251391, 16);
Thrown:
RangeError [ERR_OUT_OF_RANGE]: The value of "value" is out of range. It must be >= -2147483648 and <= 2147483647. Received 2728251391
    at checkInt (internal/buffer.js:58:11)
    at writeU_Int32LE (internal/buffer.js:678:3)
    at Buffer.writeInt32LE (internal/buffer.js:847:10)
    at repl:1:6
    at Script.runInThisContext (vm.js:126:20)
    at REPLServer.defaultEval (repl.js:384:29)
    at bound (domain.js:420:14)
    at REPLServer.runBound [as eval] (domain.js:433:12)
    at REPLServer.onLine (repl.js:700:10)
    at REPLServer.emit (events.js:208:15)

@Hakerh400
Copy link
Contributor

@imaynotbereal Option noAssert has been removed and now all methods behave like noAssert is false. Since it is released in a new semver-major version (v10.x), backward compatibility is not required. See #18395 for details.

@mscdex
Copy link
Contributor

mscdex commented Aug 8, 2019

If I call writeInt32LE() even without noAssert I still see the same error

Correct, because the default value for noAssert is/was false, meaning it will assert.

@LeavesSky
Copy link

const validateInt32 = hideStackFrames(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants