Skip to content

Commit

Permalink
Merge pull request #66 from copperybean/release-13.0.0
Browse files Browse the repository at this point in the history
Check validation of of bit offset when reading bit packed values
  • Loading branch information
al13n321 authored May 21, 2024
2 parents 8f36d71 + 48a7ea4 commit 5cfccd8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cpp/src/arrow/util/bit_stream_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,11 @@ inline void GetValue_(int num_bits, T* v, int max_bytes, const uint8_t* buffer,
#pragma warning(push)
#pragma warning(disable : 4800)
#endif
if (ARROW_PREDICT_FALSE(*bit_offset >= 64)) {
auto msg = std::string("invalid bit offset: ") + std::to_string(*bit_offset);
msg += ", may be malformed num_bits: " + std::to_string(num_bits);
throw std::runtime_error(msg);
}
*v = static_cast<T>(bit_util::TrailingBits(*buffered_values, *bit_offset + num_bits) >>
*bit_offset);
#ifdef _MSC_VER
Expand Down

0 comments on commit 5cfccd8

Please sign in to comment.