BDB may choose to use a pagesize other than 4096. As such, the parser should use the pagesize given by the BDB file.
Fixes #31210
BDB may choose to use a pagesize other than 4096. As such, the parser
should use the pagesize given by the BDB file.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/31222.
See the guideline for information on the review process.
Type | Reviewers |
---|---|
Concept ACK | theStack |
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
130@@ -132,10 +131,14 @@ def dump_bdb_kv(filename):
131 # Read in the BDB file and start deserializing it
132 pages = []
133 with open(filename, 'rb') as f:
134- data = f.read(PAGESIZE)
135+ # Read the outer meta page for the page size. It will always be at least 512 bytes.
136+ metadata = dump_meta_page(f.read(MIN_PAGESIZE))
Might want to do some basic checks on the pagesize; eg
0MIN_PAGESIZE = 512
1MAX_PAGESIZE = 65536
2⋮
3assert pagesize >= MIN_PAGESIZE and pagesize <= MAX_PAGESIZE and (pagesize & (pagesize-1) == 0)