server: Don't grow the mapped file for read-only mappings.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2016-07-27 22:20:31 +09:00
parent 32c7153fdb
commit ef716e9d1e
2 changed files with 9 additions and 3 deletions

View File

@ -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 );

View File

@ -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) */
{