From b7fb9bdeb176296f969f5771aeb3298a86aa44e4 Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Mon, 11 May 2020 14:28:01 +0300 Subject: [PATCH] mdbx: fix mdbx_xcursor_init1() for prev created databases. --- src/core.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/core.c b/src/core.c index 2ca91a84..7869f70c 100644 --- a/src/core.c +++ b/src/core.c @@ -13058,10 +13058,19 @@ static int mdbx_xcursor_init1(MDBX_cursor *mc, MDBX_node *node) { (mc->mc_db->md_flags & MDBX_DUPFIXED) ? fp->mp_leaf2_ksize : 0; } + if (unlikely(mx->mx_db.md_xsize != mc->mc_db->md_xsize)) { + if (unlikely(mc->mc_db->md_xsize != 0)) + return MDBX_CORRUPTED; + if (unlikely((mc->mc_db->md_flags & MDBX_DUPFIXED) == 0)) + return MDBX_CORRUPTED; + if (unlikely(mx->mx_db.md_xsize < mc->mc_dbx->md_vlen_min || + mx->mx_db.md_xsize > mc->mc_dbx->md_vlen_max)) + return MDBX_CORRUPTED; + mc->mc_db->md_xsize = mx->mx_db.md_xsize; + mc->mc_dbx->md_vlen_min = mc->mc_dbx->md_vlen_max = mx->mx_db.md_xsize; + } mx->mx_dbx.md_klen_min = mc->mc_dbx->md_vlen_min; mx->mx_dbx.md_klen_max = mc->mc_dbx->md_vlen_max; - if (unlikely(mx->mx_db.md_xsize != mc->mc_db->md_xsize)) - return MDBX_CORRUPTED; mdbx_debug("Sub-db -%u root page %" PRIaPGNO, mx->mx_cursor.mc_dbi, mx->mx_db.md_root);