mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-02 00:34:13 +08:00
mdbx: fix selecting/adjustment values inside mdbx_env_set_geometry()
for implicit out-of-range cases.
Fixes https://github.com/erthink/libmdbx/issues/170. Change-Id: Ibc8754811aa3d9077447220f9fec7a5543e40cc4
This commit is contained in:
parent
439cccf65f
commit
55620c1d13
@ -35,6 +35,7 @@ Fixes:
|
||||
- Fixed "reincarnation" of subDB after it deletion (https://github.com/erthink/libmdbx/issues/168).
|
||||
- Fixed (disallowing) implicit subDB deletion via operations on `@MAIN`'s DBI-handle.
|
||||
- Fixed a crash of `mdbx_env_info_ex()` in case of a call for a non-open environment (https://github.com/erthink/libmdbx/issues/171).
|
||||
- Fixed the selecting/adjustment values inside `mdbx_env_set_geometry()` for implicit out-of-range cases (https://github.com/erthink/libmdbx/issues/170).
|
||||
|
||||
|
||||
## v0.9.3 at 2021-02-02
|
||||
|
14
src/core.c
14
src/core.c
@ -10594,8 +10594,11 @@ mdbx_env_set_geometry(MDBX_env *env, intptr_t size_lower, intptr_t size_now,
|
||||
if (MIN_MAPSIZE / pagesize < MIN_PAGENO)
|
||||
size_lower = MIN_PAGENO * pagesize;
|
||||
}
|
||||
if (size_lower == INTPTR_MAX)
|
||||
if (size_lower >= INTPTR_MAX) {
|
||||
size_lower = MAX_MAPSIZE;
|
||||
if ((size_t)size_lower / pagesize > MAX_PAGENO)
|
||||
size_lower = pagesize * MAX_PAGENO;
|
||||
}
|
||||
|
||||
if (size_now <= 0) {
|
||||
size_now = DEFAULT_MAPSIZE;
|
||||
@ -10604,8 +10607,11 @@ mdbx_env_set_geometry(MDBX_env *env, intptr_t size_lower, intptr_t size_now,
|
||||
if (size_upper >= size_lower && size_now > size_upper)
|
||||
size_now = size_upper;
|
||||
}
|
||||
if (size_now == INTPTR_MAX)
|
||||
if (size_now >= INTPTR_MAX) {
|
||||
size_now = MAX_MAPSIZE;
|
||||
if ((size_t)size_now / pagesize > MAX_PAGENO)
|
||||
size_now = pagesize * MAX_PAGENO;
|
||||
}
|
||||
|
||||
if (size_upper <= 0) {
|
||||
if ((size_t)size_now >= MAX_MAPSIZE / 2)
|
||||
@ -10621,6 +10627,10 @@ mdbx_env_set_geometry(MDBX_env *env, intptr_t size_lower, intptr_t size_now,
|
||||
}
|
||||
if ((size_t)size_upper / pagesize > MAX_PAGENO)
|
||||
size_upper = pagesize * MAX_PAGENO;
|
||||
} else if (size_upper >= INTPTR_MAX) {
|
||||
size_upper = MAX_MAPSIZE;
|
||||
if ((size_t)size_upper / pagesize > MAX_PAGENO)
|
||||
size_upper = pagesize * MAX_PAGENO;
|
||||
}
|
||||
|
||||
if (unlikely(size_lower < (intptr_t)MIN_MAPSIZE || size_lower > size_upper)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user