From ddee04d991d66c70922994ba3e0770ccd8227cb4 Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Mon, 23 Nov 2020 09:25:24 +0300 Subject: [PATCH] mdbx: set DXB/LCK files position outside of a data. Set the position in files outside of the data to avoid corruption due to erroneous use of file descriptors in the application code. Change-Id: I8750f6e726edaddee254885756d5f91576a6bcb1 --- src/core.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/core.c b/src/core.c index 9380f4d8..37b8ed19 100644 --- a/src/core.c +++ b/src/core.c @@ -10806,6 +10806,13 @@ __cold int mdbx_env_open(MDBX_env *env, const char *pathname, goto bailout; } + /* Set the position in files outside of the data to avoid corruption + * due to erroneous use of file descriptors in the application code. */ + mdbx_fseek(env->me_lfd, UINT64_C(1) << 63); + mdbx_fseek(env->me_lazy_fd, UINT64_C(1) << 63); + if (env->me_dsync_fd != INVALID_HANDLE_VALUE) + mdbx_fseek(env->me_dsync_fd, UINT64_C(1) << 63); + const MDBX_env_flags_t rigorous_flags = MDBX_SAFE_NOSYNC | MDBX_DEPRECATED_MAPASYNC; const MDBX_env_flags_t mode_flags = rigorous_flags | MDBX_NOMETASYNC |