Common functions used in both the random-access file reader and the asynchronous generator
| 1236 | // Common functions used in both the random-access file reader and the |
| 1237 | // asynchronous generator |
| 1238 | Result<FileBlock> FileBlockFromFlatbuffer(const flatbuf::Block* fb_block, |
| 1239 | int64_t max_offset) { |
| 1240 | auto block = |
| 1241 | FileBlock{fb_block->offset(), fb_block->metaDataLength(), fb_block->bodyLength()}; |
| 1242 | if (block.metadata_length < 0 || block.body_length < 0 || block.offset < 0) { |
| 1243 | return Status::IOError("Invalid Block in IPC file footer"); |
| 1244 | } |
| 1245 | auto block_end = |
| 1246 | AddWithOverflow<int64_t>({block.offset, block.metadata_length, block.body_length}); |
| 1247 | if (!block_end.has_value() || block_end > max_offset) { |
| 1248 | return Status::IOError("Invalid Block in IPC file footer"); |
| 1249 | } |
| 1250 | return block; |
| 1251 | } |
| 1252 | |
| 1253 | Status CheckAligned(const FileBlock& block) { |
| 1254 | if (!bit_util::IsMultipleOf8(block.offset) || |
no test coverage detected