wallet, bdbro: Reject overflow pages without data #36886

pull kah-ja wants to merge 2 commits into bitcoin:master from kah-ja:bdbro-empty-overflow-page changing 2 files +66 −0
  1. kah-ja commented at 6:51 AM on November 16, 2026: none

    BerkeleyRODatabase::Open reads an overflow record by following next_page until it is 0. #34959 added a check that stops once more data than item_len was read, which needs every page to add data. An overflow page with hf_offset 0 adds none. If such a page names itself as next_page, the loop reads it again and again and never ends.

    This PR treats an overflow page without data as corruption.

    Behavior change: a file with an empty overflow page no longer opens and fails with Overflow page has no data. Before, an empty page with next_page 0 was accepted and the record came out shorter than item_len.

    Measurement: regtest, RelWithDebInfo, base a527a0077a. The file has 5 pages of 4096 bytes: one key whose value is an overflow record with item_len 100, and one overflow page.

    overflow page master this PR
    hf_offset 0, next_page itself bitcoin-wallet dump at 100 % of one core, killed after 60 s fails at once, exit 1
    hf_offset 100, next_page 0 dumped in 0.11 s dumped as before

    With migratewallet on master the RPC does not return and one HTTP worker stays at 100 % CPU. Other RPCs still answer, but stop had not finished after 30 s.

    Tests: new case in tool_wallet.py that writes both files by hand. On master it hangs (killed after 90 s). Passing locally: test_bitcoin and test_runner.py with the default list. Not run: fuzz targets, lint.

    Contributed by turingpoint.

  2. wallet, bdbro: Reject overflow pages without data
    An overflow record is read by following next_page until it is 0. The
    length check added in dc3a2b9c3b6 stops the loop once more data than
    item_len was read, which needs every page to add data. An overflow
    page with hf_offset 0 adds nothing, so a page like that which names
    itself as next_page is read again and again. bitcoin-wallet dump and
    migratewallet then spin on one core and never return.
    
    BDB does not write overflow pages without data, so treat one as
    corruption.
    
    Signed-off-by: Jan Kahmen <jan@turingpoint.de>
    d5878da5ac
  3. test: Check that bdbro rejects an empty overflow page
    Write a small BDB file by hand whose only overflow page has no data
    and links to itself, and check that bitcoin-wallet dump fails instead
    of looping. A second file with a filled overflow page is dumped as
    before.
    
    Signed-off-by: Jan Kahmen <jan@turingpoint.de>
    e2f3e91d95
  4. DrahtBot commented at 6:52 AM on November 16, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process. A summary of reviews will appear here.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-11-19 19:51 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me