arrow
arrow copied to clipboard
[C++][IPC] Validate buffer bounds and replace raw pointer arithmetic in MessageDecoder
Describe the enhancement requested
In cpp/src/arrow/ipc, a few areas in streaming decoding and decompression can be made safer against invalid input buffers:
MessageDecoderImpl::ConsumeDataChunksinmessage.ccuses raw pointer offsets (static_cast<uint8_t*>(out) + offset) and manualmemcpyincrements across chunk buffers. We can replace this witharrow::util::spanand check available chunk bytes before copying.DecompressBufferinreader.ccdoes not reject negative uncompressed sizes (uncompressed_size < -1) or cases wherecompressed_size == 0 && uncompressed_size > 0. We can also add an opt-in decompression ratio limit viaIpcReadOptions(usingMultiplyWithOverflow) for services reading untrusted streams.- Untrusted FlatBuffers tables call
std::vector::reserve(e.g. inmetadata_internal.cc) without checking if the declared count fits within the remaining buffer bytes. - Pass
IpcReadOptionsintoMessageDecoderso streaming decoders can configure these limits.
Component(s)
C++