Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
be55038f
Commit
be55038f
authored
Jun 25, 2021
by
Qian Hong
Committed by
Alexandre Julliard
Jun 29, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
server: Forbid shrinking files which are mapped to memory.
Signed-off-by:
Zebediah Figura
<
z.figura12@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
4e84a553
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
17 deletions
+27
-17
file.c
dlls/kernel32/tests/file.c
+9
-9
fd.c
server/fd.c
+18
-8
No files found.
dlls/kernel32/tests/file.c
View file @
be55038f
...
...
@@ -6052,11 +6052,11 @@ static void test_eof(void)
SetLastError
(
0xdeadbeef
);
SetFilePointer
(
file
,
6
,
NULL
,
SEEK_SET
);
ret
=
SetEndOfFile
(
file
);
todo_wine
ok
(
!
ret
,
"expected failure
\n
"
);
todo_wine
ok
(
GetLastError
()
==
ERROR_USER_MAPPED_FILE
,
"got error %u
\n
"
,
GetLastError
());
ok
(
!
ret
,
"expected failure
\n
"
);
ok
(
GetLastError
()
==
ERROR_USER_MAPPED_FILE
,
"got error %u
\n
"
,
GetLastError
());
ret
=
GetFileSizeEx
(
file
,
&
file_size
);
ok
(
ret
,
"failed to get size, error %u
\n
"
,
GetLastError
());
todo_wine
ok
(
file_size
.
QuadPart
==
8
,
"got size %I64d
\n
"
,
file_size
.
QuadPart
);
ok
(
file_size
.
QuadPart
==
8
,
"got size %I64d
\n
"
,
file_size
.
QuadPart
);
SetFilePointer
(
file
,
8192
,
NULL
,
SEEK_SET
);
ret
=
SetEndOfFile
(
file
);
...
...
@@ -6067,11 +6067,11 @@ static void test_eof(void)
SetFilePointer
(
file
,
8191
,
NULL
,
SEEK_SET
);
ret
=
SetEndOfFile
(
file
);
todo_wine
ok
(
!
ret
,
"expected failure
\n
"
);
todo_wine
ok
(
GetLastError
()
==
ERROR_USER_MAPPED_FILE
,
"got error %u
\n
"
,
GetLastError
());
ok
(
!
ret
,
"expected failure
\n
"
);
ok
(
GetLastError
()
==
ERROR_USER_MAPPED_FILE
,
"got error %u
\n
"
,
GetLastError
());
ret
=
GetFileSizeEx
(
file
,
&
file_size
);
ok
(
ret
,
"failed to get size, error %u
\n
"
,
GetLastError
());
todo_wine
ok
(
file_size
.
QuadPart
==
8192
,
"got size %I64d
\n
"
,
file_size
.
QuadPart
);
ok
(
file_size
.
QuadPart
==
8192
,
"got size %I64d
\n
"
,
file_size
.
QuadPart
);
view
=
MapViewOfFile
(
mapping
,
map_tests
[
i
].
view_access
,
0
,
0
,
4
);
ok
(
!!
view
,
"failed to map view, error %u
\n
"
,
GetLastError
());
...
...
@@ -6087,11 +6087,11 @@ static void test_eof(void)
SetFilePointer
(
file
,
16383
,
NULL
,
SEEK_SET
);
ret
=
SetEndOfFile
(
file
);
todo_wine
ok
(
!
ret
,
"expected failure
\n
"
);
todo_wine
ok
(
GetLastError
()
==
ERROR_USER_MAPPED_FILE
,
"got error %u
\n
"
,
GetLastError
());
ok
(
!
ret
,
"expected failure
\n
"
);
ok
(
GetLastError
()
==
ERROR_USER_MAPPED_FILE
,
"got error %u
\n
"
,
GetLastError
());
ret
=
GetFileSizeEx
(
file
,
&
file_size
);
ok
(
ret
,
"failed to get size, error %u
\n
"
,
GetLastError
());
todo_wine
ok
(
file_size
.
QuadPart
==
16384
,
"got size %I64d
\n
"
,
file_size
.
QuadPart
);
ok
(
file_size
.
QuadPart
==
16384
,
"got size %I64d
\n
"
,
file_size
.
QuadPart
);
ret
=
UnmapViewOfFile
(
view
);
ok
(
ret
,
"failed to unmap view, error %u
\n
"
,
GetLastError
());
...
...
server/fd.c
View file @
be55038f
...
...
@@ -2645,15 +2645,25 @@ static void set_fd_eof( struct fd *fd, file_pos_t eof )
set_error
(
fd
->
no_fd_status
);
return
;
}
/* first try normal truncate */
if
(
ftruncate
(
fd
->
unix_fd
,
eof
)
!=
-
1
)
return
;
/* now check for the need to extend the file */
if
(
fstat
(
fd
->
unix_fd
,
&
st
)
!=
-
1
&&
eof
>
st
.
st_size
)
grow_file
(
fd
->
unix_fd
,
eof
);
else
if
(
fstat
(
fd
->
unix_fd
,
&
st
)
==
-
1
)
{
file_set_error
();
return
;
}
if
(
eof
<
st
.
st_size
)
{
struct
fd
*
fd_ptr
;
LIST_FOR_EACH_ENTRY
(
fd_ptr
,
&
fd
->
inode
->
open
,
struct
fd
,
inode_entry
)
{
if
(
fd_ptr
->
access
&
FILE_MAPPING_ACCESS
)
{
set_error
(
STATUS_USER_MAPPED_FILE
);
return
;
}
}
if
(
ftruncate
(
fd
->
unix_fd
,
eof
)
==
-
1
)
file_set_error
();
}
else
grow_file
(
fd
->
unix_fd
,
eof
);
}
struct
completion
*
fd_get_completion
(
struct
fd
*
fd
,
apc_param_t
*
p_key
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment