dbwrapper: make max_file_size a configurable DBParams field
What changed, and why it matters
This change makes a LevelDB database file-size setting configurable rather than hard-coded. It is described by the author as useful for fuzzing (automated testing with random inputs). There is no direct security fix here; it is a test/development plumbing change.
No security action required. Treat as normal refactoring/test-infrastructure change. If reviewing callers, confirm that production code continues to use the default `DBWRAPPER_MAX_FILE_SIZE` and that only fuzz harnesses supply non-default values.
Security signals we found
No security-relevant signal in the diff itself
Commit message frames change as useful for fuzzing, not as a vulnerability fix
Evidence from the diff
The commit removes a hard-coded override of options.max_file_size inside GetOptions() and instead exposes max_file_size as a field in the DBParams struct, defaulting to the existing constant DBWRAPPER_MAX_FILE_SIZE. CDBWrapper now assigns the value from params.max_file_size directly. This allows fuzz tests to vary the SST file size without changing global behavior for production code paths.
Changed components
src/dbwrapper.cppsrc/dbwrapper.hLevelDB wrapper / DBParams configurationInspect captured patch +4 / −1
diff --git a/src/dbwrapper.cpp b/src/dbwrapper.cpp
index eb222078..ee6419d2 100644
--- a/src/dbwrapper.cpp
+++ b/src/dbwrapper.cpp
@@ -149,7 +149,6 @@ static leveldb::Options GetOptions(size_t nCacheSize)
// on corruption in later versions.
options.paranoid_checks = true;
}
- options.max_file_size = std::max(options.max_file_size, DBWRAPPER_MAX_FILE_SIZE);
SetMaxOpenFiles(&options);
return options;
}
@@ -224,6 +223,7 @@ CDBWrapper::CDBWrapper(const DBParams& params)
DBContext().syncoptions.sync = true;
DBContext().options = GetOptions(params.cache_bytes);
DBContext().options.create_if_missing = true;
+ DBContext().options.max_file_size = params.max_file_size;
if (params.memory_only) {
DBContext().penv = leveldb::NewMemEnv(leveldb::Env::Default());
DBContext().options.env = DBContext().penv;
diff --git a/src/dbwrapper.h b/src/dbwrapper.h
index 2eee6c1c..c3686400 100644
--- a/src/dbwrapper.h
+++ b/src/dbwrapper.h
@@ -44,6 +44,9 @@ struct DBParams {
bool obfuscate = false;
//! Passed-through options.
DBOptions options{};
+ //! Maximum LevelDB SST file size. Larger values reduce the frequency
+ //! of compactions but increase their duration.
+ size_t max_file_size = DBWRAPPER_MAX_FILE_SIZE;
};
class dbwrapper_error : public std::runtime_error
Why this scored 19/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.