Commit 24f7869e authored by Alexandre Julliard's avatar Alexandre Julliard

server: Enforce a mapping size limit instead of relying on the Unix file system.

parent 3504f138
...@@ -3105,6 +3105,7 @@ static void test_MapFile(void) ...@@ -3105,6 +3105,7 @@ static void test_MapFile(void)
{ {
HANDLE handle; HANDLE handle;
HANDLE hmap; HANDLE hmap;
UINT err;
ok(test_Mapfile_createtemp(&handle), "Couldn't create test file.\n"); ok(test_Mapfile_createtemp(&handle), "Couldn't create test file.\n");
...@@ -3123,15 +3124,17 @@ static void test_MapFile(void) ...@@ -3123,15 +3124,17 @@ static void test_MapFile(void)
ok(test_Mapfile_createtemp(&handle), "Couldn't create test file.\n"); ok(test_Mapfile_createtemp(&handle), "Couldn't create test file.\n");
SetLastError( 0xdeadbeef );
hmap = CreateFileMappingA( handle, NULL, PAGE_READWRITE, 0, 0, NULL ); hmap = CreateFileMappingA( handle, NULL, PAGE_READWRITE, 0, 0, NULL );
err = GetLastError();
ok( hmap == NULL, "mapped zero size file\n"); ok( hmap == NULL, "mapped zero size file\n");
ok( GetLastError() == ERROR_FILE_INVALID, "not ERROR_FILE_INVALID\n"); ok( err == ERROR_FILE_INVALID, "got %u\n", err );
hmap = CreateFileMappingA( handle, NULL, PAGE_READWRITE, 0x80000, 0, NULL );
ok( hmap == NULL, "mapping should fail\n");
hmap = CreateFileMappingA( handle, NULL, PAGE_READWRITE, 0x80000, 0x10000, NULL ); SetLastError( 0xdeadbeef );
hmap = CreateFileMappingA( handle, NULL, PAGE_READWRITE, 0x8000000, 0x10000, NULL );
err = GetLastError();
ok( hmap == NULL, "mapping should fail\n"); ok( hmap == NULL, "mapping should fail\n");
ok( err == ERROR_NOT_ENOUGH_MEMORY || err == ERROR_INVALID_PARAMETER, "got %u\n", err );
/* On XP you can now map again, on Win 95 you cannot. */ /* On XP you can now map again, on Win 95 you cannot. */
......
...@@ -993,7 +993,7 @@ static struct mapping *create_mapping( struct object *root, const struct unicode ...@@ -993,7 +993,7 @@ static struct mapping *create_mapping( struct object *root, const struct unicode
} }
else if (st.st_size < mapping->size) else if (st.st_size < mapping->size)
{ {
if (!(file_access & FILE_WRITE_DATA)) if (!(file_access & FILE_WRITE_DATA) || mapping->size >> 54 /* ntfs limit */)
{ {
set_error( STATUS_SECTION_TOO_BIG ); set_error( STATUS_SECTION_TOO_BIG );
goto error; goto error;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment