mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-14 14:59:52 -04:00
Two more checks
This commit is contained in:
parent
72f56004ec
commit
69fc251cd6
@ -265,6 +265,9 @@ class block_cache_ final : public block_cache::impl {
|
|||||||
|
|
||||||
void set_block_size(size_t size) override {
|
void set_block_size(size_t size) override {
|
||||||
// XXX: This currently inevitably clears the cache
|
// XXX: This currently inevitably clears the cache
|
||||||
|
if (size == 0) {
|
||||||
|
DWARFS_THROW(runtime_error, "block size is zero");
|
||||||
|
}
|
||||||
auto max_blocks = std::max<size_t>(options_.max_bytes / size, 1);
|
auto max_blocks = std::max<size_t>(options_.max_bytes / size, 1);
|
||||||
|
|
||||||
if (!block_.empty() && max_blocks > block_.size()) {
|
if (!block_.empty() && max_blocks > block_.size()) {
|
||||||
|
@ -225,6 +225,10 @@ void check_packed_tables(global_metadata::Meta const* meta) {
|
|||||||
void check_chunks(global_metadata::Meta const* meta) {
|
void check_chunks(global_metadata::Meta const* meta) {
|
||||||
auto block_size = meta->block_size();
|
auto block_size = meta->block_size();
|
||||||
|
|
||||||
|
if (block_size == 0 || (block_size & (block_size - 1))) {
|
||||||
|
DWARFS_THROW(runtime_error, "invalid block size");
|
||||||
|
}
|
||||||
|
|
||||||
for (auto c : meta->chunks()) {
|
for (auto c : meta->chunks()) {
|
||||||
if (c.offset() >= block_size || c.size() > block_size) {
|
if (c.offset() >= block_size || c.size() > block_size) {
|
||||||
DWARFS_THROW(runtime_error, "chunk offset/size out of range");
|
DWARFS_THROW(runtime_error, "chunk offset/size out of range");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user