Skip to content

Commit c07fdd6

Browse files
committed
fuzz: Don't compile BDB-specific code on MSVC in wallet_bdb_parser.cpp
1 parent e07a3ed commit c07fdd6

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/wallet/test/fuzz/wallet_bdb_parser.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
#include <fstream>
1919
#include <iostream>
2020

21+
// There is an inconsistency in BDB on Windows.
22+
// See: https://github.com/bitcoin/bitcoin/pull/26606#issuecomment-2322763212
23+
#undef USE_BDB_NON_MSVC
24+
#if defined(USE_BDB) && !defined(_MSC_VER)
25+
#define USE_BDB_NON_MSVC
26+
#endif
27+
2128
using wallet::DatabaseOptions;
2229
using wallet::DatabaseStatus;
2330

@@ -50,15 +57,15 @@ FUZZ_TARGET(wallet_bdb_parser, .init = initialize_wallet_bdb_parser)
5057
}
5158
g_setup->m_args.ForceSetArg("-dumpfile", fs::PathToString(bdb_ro_dumpfile));
5259

53-
#ifdef USE_BDB
60+
#ifdef USE_BDB_NON_MSVC
5461
bool bdb_ro_err = false;
5562
bool bdb_ro_strict_err = false;
5663
#endif
5764
auto db{MakeBerkeleyRODatabase(wallet_path, options, status, error)};
5865
if (db) {
5966
assert(DumpWallet(g_setup->m_args, *db, error));
6067
} else {
61-
#ifdef USE_BDB
68+
#ifdef USE_BDB_NON_MSVC
6269
bdb_ro_err = true;
6370
#endif
6471
if (error.original.starts_with("AutoFile::ignore: end of file") ||
@@ -90,15 +97,15 @@ FUZZ_TARGET(wallet_bdb_parser, .init = initialize_wallet_bdb_parser)
9097
error.original == "Subdatabase has an unexpected name" ||
9198
error.original == "Unsupported BDB data file version number" ||
9299
error.original == "BDB builtin encryption is not supported") {
93-
#ifdef USE_BDB
100+
#ifdef USE_BDB_NON_MSVC
94101
bdb_ro_strict_err = true;
95102
#endif
96103
} else {
97104
throw std::runtime_error(error.original);
98105
}
99106
}
100107

101-
#ifdef USE_BDB
108+
#ifdef USE_BDB_NON_MSVC
102109
// Try opening with BDB
103110
fs::path bdb_dumpfile{g_setup->m_args.GetDataDirNet() / "fuzzed_dumpfile_bdb.dump"};
104111
if (fs::exists(bdb_dumpfile)) { // Writing into an existing dump file will throw an exception

0 commit comments

Comments
 (0)