From 6a074cb85a7c943f7a660f0b05043b4239c13483 Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Thu, 22 Mar 2018 21:10:14 +0300 Subject: [PATCH] mdbx: fix unaligned access to mp_ptrs[] on fake-page. Based on http://www.openldap.org/devel/gitweb.cgi?p=openldap.git;a=commitdiff;h=e77918a903d980ff789b7e32f71725481e870510 --- src/mdbx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mdbx.c b/src/mdbx.c index 1d11303d..91fccbad 100644 --- a/src/mdbx.c +++ b/src/mdbx.c @@ -7406,9 +7406,11 @@ int mdbx_cursor_put(MDBX_cursor *mc, MDBX_val *key, MDBX_val *data, memcpy((char *)mp + mp->mp_upper + PAGEHDRSZ, (char *)fp + fp->mp_upper + PAGEHDRSZ, olddata.iov_len - fp->mp_upper - PAGEHDRSZ); + memcpy((char *)(&mp->mp_ptrs), (char *)(&fp->mp_ptrs), + NUMKEYS(fp) * sizeof(mp->mp_ptrs[0])); for (i = 0; i < NUMKEYS(fp); i++) { - mdbx_cassert(mc, fp->mp_ptrs[i] + offset <= UINT16_MAX); - mp->mp_ptrs[i] = (indx_t)(fp->mp_ptrs[i] + offset); + mdbx_cassert(mc, mp->mp_ptrs[i] + offset <= UINT16_MAX); + mp->mp_ptrs[i] += (indx_t)offset; } } }