From ef716e9d1eb3c0a46582d1ef28f6ca13d5af56dd Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 27 Jul 2016 22:20:31 +0900 Subject: [PATCH] server: Don't grow the mapped file for read-only mappings. Signed-off-by: Alexandre Julliard --- dlls/kernel32/tests/virtual.c | 2 -- server/mapping.c | 10 +++++++++- 2 files changed, 9 insertions(+), 3 deletions(-) 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) */ {