|
18 | 18 | #include <fstream>
|
19 | 19 | #include <iostream>
|
20 | 20 |
|
| 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 | + |
21 | 28 | using wallet::DatabaseOptions;
|
22 | 29 | using wallet::DatabaseStatus;
|
23 | 30 |
|
@@ -50,15 +57,15 @@ FUZZ_TARGET(wallet_bdb_parser, .init = initialize_wallet_bdb_parser)
|
50 | 57 | }
|
51 | 58 | g_setup->m_args.ForceSetArg("-dumpfile", fs::PathToString(bdb_ro_dumpfile));
|
52 | 59 |
|
53 |
| -#ifdef USE_BDB |
| 60 | +#ifdef USE_BDB_NON_MSVC |
54 | 61 | bool bdb_ro_err = false;
|
55 | 62 | bool bdb_ro_strict_err = false;
|
56 | 63 | #endif
|
57 | 64 | auto db{MakeBerkeleyRODatabase(wallet_path, options, status, error)};
|
58 | 65 | if (db) {
|
59 | 66 | assert(DumpWallet(g_setup->m_args, *db, error));
|
60 | 67 | } else {
|
61 |
| -#ifdef USE_BDB |
| 68 | +#ifdef USE_BDB_NON_MSVC |
62 | 69 | bdb_ro_err = true;
|
63 | 70 | #endif
|
64 | 71 | if (error.original.starts_with("AutoFile::ignore: end of file") ||
|
@@ -90,15 +97,15 @@ FUZZ_TARGET(wallet_bdb_parser, .init = initialize_wallet_bdb_parser)
|
90 | 97 | error.original == "Subdatabase has an unexpected name" ||
|
91 | 98 | error.original == "Unsupported BDB data file version number" ||
|
92 | 99 | error.original == "BDB builtin encryption is not supported") {
|
93 |
| -#ifdef USE_BDB |
| 100 | +#ifdef USE_BDB_NON_MSVC |
94 | 101 | bdb_ro_strict_err = true;
|
95 | 102 | #endif
|
96 | 103 | } else {
|
97 | 104 | throw std::runtime_error(error.original);
|
98 | 105 | }
|
99 | 106 | }
|
100 | 107 |
|
101 |
| -#ifdef USE_BDB |
| 108 | +#ifdef USE_BDB_NON_MSVC |
102 | 109 | // Try opening with BDB
|
103 | 110 | fs::path bdb_dumpfile{g_setup->m_args.GetDataDirNet() / "fuzzed_dumpfile_bdb.dump"};
|
104 | 111 | if (fs::exists(bdb_dumpfile)) { // Writing into an existing dump file will throw an exception
|
|
0 commit comments