From e2b0984f99519f76423ce26ce9077ca765b2b30b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C5=91rinc?= Date: Wed, 6 May 2026 12:34:20 +0200 Subject: [PATCH] wallet: check BDB last page LSN The BDB metadata field `last_page` stores the last valid page number, not the number of pages. The read-only wallet migration parser currently checks reset LSNs with a half-open loop, so it skips the final page and may accept a database whose last page still depends on BDB log files. --- src/wallet/migrate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/migrate.cpp b/src/wallet/migrate.cpp index 1869a456671..f42aa2be951 100644 --- a/src/wallet/migrate.cpp +++ b/src/wallet/migrate.cpp @@ -567,7 +567,7 @@ void BerkeleyRODatabase::Open() // Check all Log Sequence Numbers (LSN) point to file 0 and offset 1 which indicates that the LSNs were // reset and that the log files are not necessary to get all of the data in the database. - for (uint32_t i = 0; i < outer_meta.last_page; ++i) { + for (uint32_t i = 0; i <= outer_meta.last_page; ++i) { // The LSN is composed of 2 32-bit ints, the first is a file id, the second an offset // It will always be the first 8 bytes of a page, so we deserialize it directly for every page uint32_t file;