diff options
author | Charlie Gordon <github@chqrlie.org> | 2024-02-17 21:15:29 +0100 |
---|---|---|
committer | Charlie Gordon <github@chqrlie.org> | 2024-02-17 21:15:29 +0100 |
commit | 85fb2caeae86bc7962ff8740f24a3f462e8b3f53 (patch) | |
tree | cef1e7770ab68982045d51e0349feb1d0a58f2f7 /tests | |
parent | 8df432755914ca02476b34d9bf0e54e21d75b05f (diff) | |
download | quickjs-85fb2caeae86bc7962ff8740f24a3f462e8b3f53.tar.gz quickjs-85fb2caeae86bc7962ff8740f24a3f462e8b3f53.zip |
Fix UB signed integer overflow in js_math_imul
- Use uint32_t arithmetics and Standard conformant conversion to
avoid UB in js_math_imul.
- add builtin tests
- use specific object directories for SAN targets
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_builtin.js | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/test_builtin.js b/tests/test_builtin.js index a9b2264..b6a1c2d 100644 --- a/tests/test_builtin.js +++ b/tests/test_builtin.js @@ -311,6 +311,10 @@ function test_math() assert(Math.floor(a), 1); assert(Math.ceil(a), 2); assert(Math.imul(0x12345678, 123), -1088058456); + assert(Math.imul(0xB505, 0xB504), 2147441940); + assert(Math.imul(0xB505, 0xB505), -2147479015); + assert(Math.imul((-2)**31, (-2)**31), 0); + assert(Math.imul(2**31-1, 2**31-1), 1); assert(Math.fround(0.1), 0.10000000149011612); assert(Math.hypot() == 0); assert(Math.hypot(-2) == 2); |