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 |