mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-21 07:39:08 +01:00
blockstorage: simplify partial block read validation
Use `SaturatingAdd` following https://github.com/bitcoin/bitcoin/pull/33657#discussion_r2610832092.
This commit is contained in:
@@ -1083,7 +1083,7 @@ BlockManager::ReadRawBlockResult BlockManager::ReadRawBlock(const FlatFilePos& p
|
||||
|
||||
if (block_part) {
|
||||
const auto [offset, size]{*block_part};
|
||||
if (size == 0 || offset >= blk_size || size > blk_size - offset) {
|
||||
if (size == 0 || SaturatingAdd(offset, size) > blk_size) {
|
||||
return util::Unexpected{ReadRawError::BadPartRange}; // Avoid logging - offset/size come from untrusted REST input
|
||||
}
|
||||
filein.seek(offset, SEEK_CUR);
|
||||
|
||||
Reference in New Issue
Block a user