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

Alexandre Julliard julliard at winehq.org
Wed Jul 27 10:30:58 CDT 2016


Module: wine
Branch: master
Commit: ef716e9d1eb3c0a46582d1ef28f6ca13d5af56dd
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=ef716e9d1eb3c0a46582d1ef28f6ca13d5af56dd

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Wed Jul 27 22:20:31 2016 +0900

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

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 26cf09f..583abf6 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 1015a23..b68f281 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) */
     {




More information about the wine-cvs mailing list