Describe the bug
The Feather V1 writer shifts bitmap bytes when serializing a sliced Boolean
array or validity bitmap. On the final output byte, the shift loop
unconditionally reads the next source byte even when the logical slice ends in
the current byte.
A valid ArrayData backed by an exact-sized Buffer therefore causes a
one-byte heap-buffer-overflow read. The adjacent bit is also folded into the
unused bits of the serialized bitmap byte.
Component
C++ IPC / Feather V1 writer.
Version
Reproduced on current main at
35c5ffd12173284406e4a2c86405415444e596d7.
Minimal reproduction
auto owner = std::make_unique<uint8_t[]>(1);
owner[0] = 0x03;
auto values = std::make_shared<arrow::Buffer>(owner.get(), 1);
auto data = arrow::ArrayData::Make(arrow::boolean(), 1, {nullptr, values},
/*null_count=*/0, /*offset=*/1);
auto array = arrow::MakeArray(data);
auto table = arrow::Table::Make(
arrow::schema({arrow::field("flag", arrow::boolean())}),
{std::make_shared<arrow::ChunkedArray>(array)});
ARROW_ASSIGN_OR_RAISE(auto sink, arrow::io::BufferOutputStream::Create());
auto properties = arrow::ipc::feather::WriteProperties::DefaultsV1();
ARROW_RETURN_NOT_OK(
arrow::ipc::feather::WriteTable(*table, sink.get(), properties));
Under ASan, the write deterministically reports a one-byte
heap-buffer-overflow read in WritePaddedWithOffset in
cpp/src/arrow/ipc/feather.cc.
The same harness with offset = 0 completes without a sanitizer error.
Expected behavior
The writer should read only the bitmap bytes required by the logical slice and
clear unused trailing bits in the serialized bitmap byte.
Describe the bug
The Feather V1 writer shifts bitmap bytes when serializing a sliced Boolean
array or validity bitmap. On the final output byte, the shift loop
unconditionally reads the next source byte even when the logical slice ends in
the current byte.
A valid
ArrayDatabacked by an exact-sizedBuffertherefore causes aone-byte heap-buffer-overflow read. The adjacent bit is also folded into the
unused bits of the serialized bitmap byte.
Component
C++ IPC / Feather V1 writer.
Version
Reproduced on current
mainat35c5ffd12173284406e4a2c86405415444e596d7.Minimal reproduction
Under ASan, the write deterministically reports a one-byte
heap-buffer-overflow read in
WritePaddedWithOffsetincpp/src/arrow/ipc/feather.cc.The same harness with
offset = 0completes without a sanitizer error.Expected behavior
The writer should read only the bitmap bytes required by the logical slice and
clear unused trailing bits in the serialized bitmap byte.