mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-31 10:41:08 +00:00
blockstorage: simplify partial block read validation
Use `SaturatingAdd` following https://github.com/bitcoin/bitcoin/pull/33657#discussion_r2610832092.
This commit is contained in:
parent
599effdeab
commit
41118e17f8
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user