1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 16:18:12 +00:00
serenity/Userland
Daniel Bertalan 12dc2c2079 LibJS: Fix wraparound UB in Value::to_u{8,16}
If we call these two functions on a negative value, undefined behavior
occurs due to casting a negative double to an unsigned integer. These
functions are defined to perform modular arithmetic, so negative values
can be fixed up by adding 2^8/2^16.

The reason why this step is not mentioned in ECMA-262 is that it defines
modular arithmetic so that `x mod m` had the same sign as `m`, while
LibM's `fmod(x, m)` copies `x`'s sign.

This issue was found by UBSAN with the Clang toolchain.
2021-08-08 10:55:36 +02:00
..
Applets Everywhere: Replace Model::update() with Model::invalidate() 2021-08-06 19:14:31 +02:00
Applications SystemMonitor: Remove unused this lambda captures 2021-08-08 10:55:36 +02:00
Demos Everywhere: Replace Model::update() with Model::invalidate() 2021-08-06 19:14:31 +02:00
DevTools UserspaceEmulator: Use for_each_region_of_type in find_text_region 2021-08-08 10:55:36 +02:00
DynamicLoader Meta: Add Clang support to the CMake build scripts 2021-08-08 10:55:36 +02:00
Games Solitaire: Don't allow the player to draw cards while mouse is down 2021-08-07 16:59:46 +02:00
Libraries LibJS: Fix wraparound UB in Value::to_u{8,16} 2021-08-08 10:55:36 +02:00
Services WindowServer: Fix Clang crash when compiling Compositor.cpp 2021-08-08 10:55:36 +02:00
Shell Shell: Make sure TTY echo is enabled when running external commands 2021-08-04 03:14:59 +04:30
Utilities LibCpp: Do lexing in the Preprocessor 2021-08-07 21:24:11 +02:00
CMakeLists.txt Tests: Establish root Tests directory, move Userland/Tests there 2021-05-06 17:54:28 +02:00