Skip to content

Commit 46d3477

Browse files
committed
Merge bitcoin/bitcoin#30172: fuzz: Handle missing BDBRO errors
9ddf39d fuzz: Handle missing BDBRO errors (Ava Chow) Pull request description: Adds error messages that were not being handled. Also removes error messages that no longer exist. Fixes #30166 ACKs for top commit: dergoegge: reACK 9ddf39d TheCharlatan: ACK 9ddf39d Tree-SHA512: 2597536a1e5d030653dfcb02fd892f7492f5a091def787f6cbd421b8bca9544847684a498e9458ea99ae7de5a8a6d91532ff904d1e39222d324939d31d2eb3f0
2 parents be100cf + 9ddf39d commit 46d3477

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/wallet/test/fuzz/wallet_bdb_parser.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ FUZZ_TARGET(wallet_bdb_parser, .init = initialize_wallet_bdb_parser)
5252

5353
#ifdef USE_BDB
5454
bool bdb_ro_err = false;
55-
bool bdb_ro_pgno_err = false;
55+
bool bdb_ro_strict_err = false;
5656
#endif
5757
auto db{MakeBerkeleyRODatabase(wallet_path, options, status, error)};
5858
if (db) {
@@ -64,30 +64,33 @@ FUZZ_TARGET(wallet_bdb_parser, .init = initialize_wallet_bdb_parser)
6464
if (error.original.starts_with("AutoFile::ignore: end of file") ||
6565
error.original.starts_with("AutoFile::read: end of file") ||
6666
error.original == "Not a BDB file" ||
67-
error.original == "Unsupported BDB data file version number" ||
6867
error.original == "Unexpected page type, should be 9 (BTree Metadata)" ||
6968
error.original == "Unexpected database flags, should only be 0x20 (subdatabases)" ||
7069
error.original == "Unexpected outer database root page type" ||
7170
error.original == "Unexpected number of entries in outer database root page" ||
72-
error.original == "Subdatabase has an unexpected name" ||
7371
error.original == "Subdatabase page number has unexpected length" ||
74-
error.original == "Unexpected inner database page type" ||
7572
error.original == "Unknown record type in records page" ||
7673
error.original == "Unknown record type in internal page" ||
7774
error.original == "Unexpected page size" ||
7875
error.original == "Unexpected page type" ||
7976
error.original == "Page number mismatch" ||
8077
error.original == "Bad btree level" ||
8178
error.original == "Bad page size" ||
82-
error.original == "File size is not a multiple of page size" ||
83-
error.original == "Meta page number mismatch") {
79+
error.original == "Meta page number mismatch" ||
80+
error.original == "Data record position not in page" ||
81+
error.original == "Internal record position not in page" ||
82+
error.original == "LSNs are not reset, this database is not completely flushed. Please reopen then close the database with a version that has BDB support" ||
83+
error.original == "Records page has odd number of records" ||
84+
error.original == "Bad overflow record page type") {
8485
// Do nothing
8586
} else if (error.original == "Subdatabase last page is greater than database last page" ||
8687
error.original == "Page number is greater than database last page" ||
87-
error.original == "Page number is greater than subdatabase last page" ||
88-
error.original == "Last page number could not fit in file") {
88+
error.original == "Last page number could not fit in file" ||
89+
error.original == "Subdatabase has an unexpected name" ||
90+
error.original == "Unsupported BDB data file version number" ||
91+
error.original == "BDB builtin encryption is not supported") {
8992
#ifdef USE_BDB
90-
bdb_ro_pgno_err = true;
93+
bdb_ro_strict_err = true;
9194
#endif
9295
} else {
9396
throw std::runtime_error(error.original);
@@ -108,9 +111,8 @@ FUZZ_TARGET(wallet_bdb_parser, .init = initialize_wallet_bdb_parser)
108111
return;
109112
}
110113
assert(db);
111-
if (bdb_ro_pgno_err) {
112-
// BerkeleyRO will throw on opening for errors involving bad page numbers, but BDB does not.
113-
// Ignore those.
114+
if (bdb_ro_strict_err) {
115+
// BerkeleyRO will be stricter than BDB. Ignore when those specific errors are hit.
114116
return;
115117
}
116118
assert(!bdb_ro_err);

0 commit comments

Comments
 (0)