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

(cherry picked from commit 5cfccd8)
  • Loading branch information
al13n321 authored and nikitamikhaylov committed Oct 15, 2024
1 parent 57986f2 commit 39e53db
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 @@ -272,6 +272,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 39e53db

Please sign in to comment.