diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c index 26cf09f8ed7..583abf67f18 100644 --- a/dlls/kernel32/tests/virtual.c +++ b/dlls/kernel32/tests/virtual.c @@ -1014,9 +1014,7 @@ static void test_MapViewOfFile(void) map_size.QuadPart = 0x3457; status = pNtCreateSection( &mapping, SECTION_QUERY | SECTION_MAP_READ, NULL, &map_size, PAGE_READONLY, SEC_COMMIT, file ); - todo_wine ok( status == STATUS_SECTION_TOO_BIG, "NtCreateSection failed %x\n", status ); - if (!status) CloseHandle( mapping ); status = pNtCreateSection( &mapping, SECTION_QUERY | SECTION_MAP_READ, NULL, &map_size, PAGE_READONLY, SEC_IMAGE, file ); ok( status == STATUS_INVALID_IMAGE_NOT_MZ, "NtCreateSection failed %x\n", status ); diff --git a/server/mapping.c b/server/mapping.c index 1015a2372e5..b68f2817f6b 100644 --- a/server/mapping.c +++ b/server/mapping.c @@ -574,7 +574,15 @@ static struct object *create_mapping( struct object *root, const struct unicode_ goto error; } } - else if (st.st_size < mapping->size && !grow_file( unix_fd, mapping->size )) goto error; + else if (st.st_size < mapping->size) + { + if (!(access & FILE_WRITE_DATA)) + { + set_error( STATUS_SECTION_TOO_BIG ); + goto error; + } + if (!grow_file( unix_fd, mapping->size )) goto error; + } } else /* Anonymous mapping (no associated file) */ {