You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: add safe double-to-int64 conversion for bitwise operations
Implements proper safety checks for all bitwise operations (<<, >>, &, ^, |)
when converting double values to int64_t. This prevents undefined behavior
and potential security issues from integer overflow or invalid values.
The implementation:
- Adds safeDoubleToInt64 function to safely convert doubles to int64_t
- Applies this function to all bitwise operations in vm.cpp
- Validates that values are finite (not NaN or Infinity)
- Ensures values are within valid int64_t range
- Provides proper error reporting with source location context
This change aligns with the Jsonnet specification which states that bitwise
operations should first convert operands to signed 64-bit integers before
performing operations. The previous implementation performed unchecked casts
that could lead to undefined behavior with extreme values.
Signed-off-by: Ville Vesilehto <[email protected]>
0 commit comments