You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ks...@apache.org on 2020/05/13 01:15:28 UTC
[arrow] 12/17: ARROW-8728: [C++] Fix bitmap operation buffer
overflow
This is an automated email from the ASF dual-hosted git repository.
kszucs pushed a commit to branch maint-0.17.x
in repository https://gitbox.apache.org/repos/asf/arrow.git
commit 57da2c186769f42ace236c60611706daf5c74adb
Author: Yibo Cai <yi...@arm.com>
AuthorDate: Thu May 7 14:27:12 2020 +0200
ARROW-8728: [C++] Fix bitmap operation buffer overflow
Closes #7123 from cyb70289/bitmap-bug
Authored-by: Yibo Cai <yi...@arm.com>
Signed-off-by: Antoine Pitrou <an...@python.org>
---
cpp/src/arrow/util/bit_util.cc | 2 +-
cpp/src/arrow/util/bit_util_test.cc | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/cpp/src/arrow/util/bit_util.cc b/cpp/src/arrow/util/bit_util.cc
index 15bc561..5f17838 100644
--- a/cpp/src/arrow/util/bit_util.cc
+++ b/cpp/src/arrow/util/bit_util.cc
@@ -264,7 +264,7 @@ void AlignedBitmapOp(const uint8_t* left, int64_t left_offset, const uint8_t* ri
DCHECK_EQ(left_offset % 8, right_offset % 8);
DCHECK_EQ(left_offset % 8, out_offset % 8);
- const int64_t nbytes = BitUtil::BytesForBits(length + left_offset);
+ const int64_t nbytes = BitUtil::BytesForBits(length + left_offset % 8);
left += left_offset / 8;
right += right_offset / 8;
out += out_offset / 8;
diff --git a/cpp/src/arrow/util/bit_util_test.cc b/cpp/src/arrow/util/bit_util_test.cc
index a8e6279..e597b63 100644
--- a/cpp/src/arrow/util/bit_util_test.cc
+++ b/cpp/src/arrow/util/bit_util_test.cc
@@ -577,7 +577,7 @@ class BitmapOp : public TestBase {
std::shared_ptr<Buffer> left, right, out;
int64_t length;
- for (int64_t left_offset : {0, 1, 3, 5, 7, 8, 13, 21, 38, 75, 120}) {
+ for (int64_t left_offset : {0, 1, 3, 5, 7, 8, 13, 21, 38, 75, 120, 65536}) {
BitmapFromVector(left_bits, left_offset, &left, &length);
for (int64_t right_offset : {left_offset, left_offset + 8, left_offset + 40}) {
BitmapFromVector(right_bits, right_offset, &right, &length);
@@ -604,7 +604,7 @@ class BitmapOp : public TestBase {
const std::vector<int>& result_bits) {
std::shared_ptr<Buffer> left, right, out;
int64_t length;
- auto offset_values = {0, 1, 3, 5, 7, 8, 13, 21, 38, 75, 120};
+ auto offset_values = {0, 1, 3, 5, 7, 8, 13, 21, 38, 75, 120, 65536};
for (int64_t left_offset : offset_values) {
BitmapFromVector(left_bits, left_offset, &left, &length);