File tree Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 6
6
7
7
#include < logging.h>
8
8
#include < random.h>
9
+ #include < node/interface_ui.h>
9
10
#include < serialize.h>
10
11
#include < span.h>
11
12
#include < streams.h>
12
13
#include < util/fs.h>
13
14
#include < util/fs_helpers.h>
14
15
#include < util/strencodings.h>
16
+ #include < util/translation.h>
15
17
16
18
#include < algorithm>
17
19
#include < cassert>
18
20
#include < cstdarg>
19
21
#include < cstdint>
20
22
#include < cstdio>
23
+ #include < leveldb/c.h>
21
24
#include < leveldb/cache.h>
22
25
#include < leveldb/db.h>
23
26
#include < leveldb/env.h>
@@ -51,6 +54,22 @@ static void HandleError(const leveldb::Status& status)
51
54
throw dbwrapper_error (errmsg);
52
55
}
53
56
57
+ bool dbwrapper_SanityCheck ()
58
+ {
59
+ unsigned long header_version = (leveldb::kMajorVersion << 16 ) | leveldb::kMinorVersion ;
60
+ unsigned long library_version = (leveldb_major_version () << 16 ) | leveldb_minor_version ();
61
+
62
+ if (header_version != library_version) {
63
+ InitError (Untranslated (strprintf (" Compiled with LevelDB %d.%d, but linked with LevelDB %d.%d (incompatible)." ,
64
+ leveldb::kMajorVersion , leveldb::kMinorVersion ,
65
+ leveldb_major_version (), leveldb_minor_version ()
66
+ )));
67
+ return false ;
68
+ }
69
+
70
+ return true ;
71
+ }
72
+
54
73
class CBitcoinLevelDBLogger : public leveldb ::Logger {
55
74
public:
56
75
// This code is adapted from posix_logger.h, which is why it is using vsprintf.
Original file line number Diff line number Diff line change 20
20
#include < string>
21
21
#include < vector>
22
22
23
+ bool dbwrapper_SanityCheck ();
24
+
23
25
static const size_t DBWRAPPER_PREALLOC_KEY_SIZE = 64 ;
24
26
static const size_t DBWRAPPER_PREALLOC_VALUE_SIZE = 1024 ;
25
27
Original file line number Diff line number Diff line change 4
4
5
5
#include < kernel/checks.h>
6
6
7
+ #include < dbwrapper.h>
7
8
#include < random.h>
8
9
#include < util/result.h>
9
10
#include < util/translation.h>
@@ -14,6 +15,10 @@ namespace kernel {
14
15
15
16
util::Result<void > SanityChecks (const Context&)
16
17
{
18
+ if (!dbwrapper_SanityCheck ()) {
19
+ return util::Error{Untranslated (" Database sanity check failure. Aborting." )};
20
+ }
21
+
17
22
if (!Random_SanityCheck ()) {
18
23
return util::Error{Untranslated (" OS cryptographic RNG sanity check failure. Aborting." )};
19
24
}
You can’t perform that action at this time.
0 commit comments