mdbx: check for pgno inside mdbx_page_get().

Change-Id: I2fed589d592228c7a98a8aa76f5b6489569b13d2
This commit is contained in:
Leonid Yuriev 2018-09-14 02:04:25 +03:00
parent bf22699fb3
commit 30949031c1

View File

@ -6747,6 +6747,9 @@ mapped:
p = pgno2page(env, pgno); p = pgno2page(env, pgno);
done: done:
if (unlikely(p->mp_pgno != pgno))
return MDBX_CORRUPTED;
if (unlikely(p->mp_upper < p->mp_lower || if (unlikely(p->mp_upper < p->mp_lower ||
PAGEHDRSZ + p->mp_upper > env->me_psize) && PAGEHDRSZ + p->mp_upper > env->me_psize) &&
!IS_OVERFLOW(p)) !IS_OVERFLOW(p))
@ -12561,8 +12564,6 @@ static int __cold mdbx_env_walk(mdbx_walk_ctx_t *ctx, const char *dbi,
int rc = mdbx_page_get(&mc, pgno, &mp, NULL); int rc = mdbx_page_get(&mc, pgno, &mp, NULL);
if (rc) if (rc)
return rc; return rc;
if (pgno != mp->mp_pgno)
return MDBX_CORRUPTED;
const int nkeys = NUMKEYS(mp); const int nkeys = NUMKEYS(mp);
size_t header_size = IS_LEAF2(mp) ? PAGEHDRSZ : PAGEHDRSZ + mp->mp_lower; size_t header_size = IS_LEAF2(mp) ? PAGEHDRSZ : PAGEHDRSZ + mp->mp_lower;
@ -12624,9 +12625,6 @@ static int __cold mdbx_env_walk(mdbx_walk_ctx_t *ctx, const char *dbi,
if (rc) if (rc)
return rc; return rc;
if (large_pgno != op->mp_pgno)
return MDBX_CORRUPTED;
/* LY: Don't use mask here, e.g bitwise /* LY: Don't use mask here, e.g bitwise
* (P_BRANCH|P_LEAF|P_LEAF2|P_META|P_OVERFLOW|P_SUBP). * (P_BRANCH|P_LEAF|P_LEAF2|P_META|P_OVERFLOW|P_SUBP).
* Pages should not me marked dirty/loose or otherwise. */ * Pages should not me marked dirty/loose or otherwise. */