mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-23 16:19:35 -05:00
ITS#8324 fix for read-only envs
This commit is contained in:
parent
58d1fd4c73
commit
8b95e7d13e
1 changed files with 14 additions and 5 deletions
|
|
@ -4003,19 +4003,28 @@ mdb_env_map(MDB_env *env, void *addr)
|
|||
int access = SECTION_MAP_READ;
|
||||
HANDLE mh;
|
||||
void *map;
|
||||
size_t msize = 0;
|
||||
ULONG pageprot = PAGE_READONLY;
|
||||
size_t msize;
|
||||
ULONG pageprot = PAGE_READONLY, secprot, alloctype;
|
||||
|
||||
if (flags & MDB_WRITEMAP) {
|
||||
access |= SECTION_MAP_WRITE;
|
||||
pageprot = PAGE_READWRITE;
|
||||
}
|
||||
if (flags & MDB_RDONLY) {
|
||||
secprot = PAGE_READONLY;
|
||||
msize = 0;
|
||||
alloctype = 0;
|
||||
} else {
|
||||
secprot = PAGE_READWRITE;
|
||||
msize = env->me_mapsize;
|
||||
alloctype = MEM_RESERVE;
|
||||
}
|
||||
|
||||
rc = NtCreateSection(&mh, access, NULL, NULL, PAGE_READWRITE, SEC_RESERVE, env->me_fd);
|
||||
rc = NtCreateSection(&mh, access, NULL, NULL, secprot, SEC_RESERVE, env->me_fd);
|
||||
if (rc)
|
||||
return rc;
|
||||
map = addr;
|
||||
msize = env->me_mapsize;
|
||||
rc = NtMapViewOfSection(mh, GetCurrentProcess(), &map, 0, 0, NULL, &msize, ViewUnmap, MEM_RESERVE, pageprot);
|
||||
rc = NtMapViewOfSection(mh, GetCurrentProcess(), &map, 0, 0, NULL, &msize, ViewUnmap, alloctype, pageprot);
|
||||
NtClose(mh);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
|
|
|||
Loading…
Reference in a new issue