mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-20 05:18:21 +08:00
mdbx-check: minor refine to avoid deeply recursion.
Change-Id: I67f83a232ef47899f43c242b7e6295de4d7ec909
This commit is contained in:
parent
49d0e872a1
commit
52bc4a7f41
@ -258,6 +258,11 @@ static int pgvisitor(uint64_t pgno, unsigned pgnumber, void *ctx, int deep,
|
||||
size_t payload_bytes, size_t header_bytes,
|
||||
size_t unused_bytes) {
|
||||
(void)ctx;
|
||||
if (deep > 42) {
|
||||
problem_add("deep", deep, "too large", nullptr);
|
||||
return MDBX_CORRUPTED /* avoid infinite loop/recursion */;
|
||||
}
|
||||
|
||||
if (pagetype == MDBX_page_void)
|
||||
return MDBX_SUCCESS;
|
||||
|
||||
@ -319,9 +324,7 @@ static int pgvisitor(uint64_t pgno, unsigned pgnumber, void *ctx, int deep,
|
||||
", unused %" PRIiPTR ", deep %i\n",
|
||||
dbi->name, header_bytes, payload_bytes, unused_bytes, deep);
|
||||
}
|
||||
}
|
||||
|
||||
if (pgnumber) {
|
||||
bool already_used = false;
|
||||
do {
|
||||
if (pgno >= lastpgno)
|
||||
@ -344,11 +347,6 @@ static int pgvisitor(uint64_t pgno, unsigned pgnumber, void *ctx, int deep,
|
||||
if (already_used)
|
||||
return branch ? MDBX_RESULT_TRUE /* avoid infinite loop/recursion */
|
||||
: MDBX_SUCCESS;
|
||||
|
||||
if (deep > 42) {
|
||||
problem_add("deep", deep, "too large", nullptr);
|
||||
return MDBX_CORRUPTED /* avoid infinite loop/recursion */;
|
||||
}
|
||||
}
|
||||
|
||||
if (unused_bytes > page_size)
|
||||
|
Loading…
x
Reference in New Issue
Block a user