Common functions used in both the random-access file reader and the asynchronous generator
| 1256 | // Common functions used in both the random-access file reader and the |
| 1257 | // asynchronous generator |
| 1258 | Result<FileBlock> FileBlockFromFlatbuffer(const flatbuf::Block* fb_block, |
| 1259 | int64_t max_offset) { |
| 1260 | auto block = |
| 1261 | FileBlock{fb_block->offset(), fb_block->metaDataLength(), fb_block->bodyLength()}; |
| 1262 | if (block.metadata_length < 0 || block.body_length < 0 || block.offset < 0) { |
| 1263 | return Status::IOError("Invalid Block in IPC file footer"); |
| 1264 | } |
| 1265 | auto block_end = |
| 1266 | AddWithOverflow<int64_t>({block.offset, block.metadata_length, block.body_length}); |
| 1267 | if (!block_end.has_value() || block_end > max_offset) { |
| 1268 | return Status::IOError("Invalid Block in IPC file footer"); |
| 1269 | } |
| 1270 | return block; |
| 1271 | } |
| 1272 | |
| 1273 | Status CheckAligned(const FileBlock& block) { |
| 1274 | if (!bit_util::IsMultipleOf8(block.offset) || |
no test coverage detected