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

Inconsistent treatment with long negative number #4978

Closed
igor-simoes opened this issue Apr 12, 2018 · 1 comment
Closed

Inconsistent treatment with long negative number #4978

igor-simoes opened this issue Apr 12, 2018 · 1 comment

Comments

@igor-simoes
Copy link

igor-simoes commented Apr 12, 2018

Hello everyone,
I found a bug that could be one case of "inconsistent treatment/check of pre-conditions" with long negative number.

Chakra version: 1.9.0.0
OS: Ubuntu 16.04 x64

Steps to reproduce:

  1. Run this code
var buffer = new ArrayBuffer(64);
var view = new DataView(buffer);
view.setInt8(0,0x80);
print(view.getInt8(-1770523502845470856862803727694) === -0x80);

Expected output:
An exception with an invalid or out-of-range index

Actual results:
true

V8, SpiderMonkey and JavascriptCore shows expected results. Chakra always returns the value -128 for a long negative number on getInt8 function, note that converting -0x80 to decimal value we obtain -128 too.

cinfuzz

@rhuanjl
Copy link
Collaborator

rhuanjl commented Apr 12, 2018

All the get and set methods in DataView.cpp seem to use ToUInt32 on the offset argument they're provided, per spec looks like they should use toIndex https://tc39.github.io/ecma262/#sec-toindex which would throw range errors for any negative.

I'll make a PR to fix this.

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

No branches or pull requests

3 participants