This is an automated email from the ASF dual-hosted git repository.
dongjoon pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/orc.git
The following commit(s) were added to refs/heads/main by this push:
new eb60462b8 ORC-1946: [C++] Fix potential overflow issue in left shift
operation identified by UBSAN
eb60462b8 is described below
commit eb60462b8be4de31dc863764b833a50d5e9a9662
Author: luffy-zh <[email protected]>
AuthorDate: Wed Jul 16 07:11:35 2025 -0700
ORC-1946: [C++] Fix potential overflow issue in left shift operation
identified by UBSAN
### What changes were proposed in this pull request?
Remove some temporary workarounds in this
[PR](https://github.com/apache/orc/pull/2117).
### Why are the changes needed?
Fix potential overflow issue in left shift operation.
### How was this patch tested?
Test it locally.
### Was this patch authored or co-authored using generative AI tooling?
No.
Closes #2317 from luffy-zh/ORC-1946.
Authored-by: luffy-zh <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
---
c++/src/RLE.cc | 3 +--
c++/src/RLE.hh | 4 +---
2 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/c++/src/RLE.cc b/c++/src/RLE.cc
index 19ca558fc..b29ee8706 100644
--- a/c++/src/RLE.cc
+++ b/c++/src/RLE.cc
@@ -77,9 +77,8 @@ namespace orc {
add<int16_t>(data, numValues, notNull);
}
- NO_SANITIZE_ATTR
void RleEncoder::writeVslong(int64_t val) {
- writeVulong((val << 1) ^ (val >> 63));
+ writeVulong((static_cast<uint64_t>(val) << 1) ^ (val >> 63));
}
void RleEncoder::writeVulong(int64_t val) {
diff --git a/c++/src/RLE.hh b/c++/src/RLE.hh
index 3ad93e3dc..42c1d5b0e 100644
--- a/c++/src/RLE.hh
+++ b/c++/src/RLE.hh
@@ -25,10 +25,8 @@
#include <memory>
namespace orc {
-
- NO_SANITIZE_ATTR
inline int64_t zigZag(int64_t value) {
- return (value << 1) ^ (value >> 63);
+ return ((static_cast<uint64_t>(value) << 1) ^ (value >> 63));
}
inline int64_t unZigZag(uint64_t value) {