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
2bcef9e1
Commit
2bcef9e1
authored
Jun 17, 2004
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't use lseek when truncating a file to avoid corrupting the current
file position.
parent
d440ca4a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
8 deletions
+9
-8
file.c
dlls/ntdll/file.c
+9
-8
No files found.
dlls/ntdll/file.c
View file @
2bcef9e1
...
...
@@ -1092,22 +1092,23 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io,
case
FileEndOfFileInformation
:
if
(
len
>=
sizeof
(
FILE_END_OF_FILE_INFORMATION
))
{
struct
stat
st
;
const
FILE_END_OF_FILE_INFORMATION
*
info
=
ptr
;
if
(
info
->
EndOfFile
.
QuadPart
>
lseek
(
fd
,
0
,
SEEK_END
))
/* first try normal truncate */
if
(
ftruncate
(
fd
,
(
off_t
)
info
->
EndOfFile
.
QuadPart
)
!=
-
1
)
break
;
/* now check for the need to extend the file */
if
(
fstat
(
fd
,
&
st
)
!=
-
1
&&
(
off_t
)
info
->
EndOfFile
.
QuadPart
>
st
.
st_size
)
{
static
const
char
zero
;
/* extend the file one byte beyond the requested size and then truncate it */
/* this should work around ftruncate implementations that can't extend files */
if
(
pwrite
(
fd
,
&
zero
,
1
,
(
off_t
)
info
->
EndOfFile
.
QuadPart
)
==
-
1
)
{
io
->
u
.
Status
=
FILE_GetNtStatus
();
break
;
}
if
(
pwrite
(
fd
,
&
zero
,
1
,
(
off_t
)
info
->
EndOfFile
.
QuadPart
)
!=
-
1
&&
ftruncate
(
fd
,
(
off_t
)
info
->
EndOfFile
.
QuadPart
)
!=
-
1
)
break
;
}
if
(
ftruncate
(
fd
,
(
off_t
)
info
->
EndOfFile
.
QuadPart
)
==
-
1
)
io
->
u
.
Status
=
FILE_GetNtStatus
();
io
->
u
.
Status
=
FILE_GetNtStatus
();
}
else
io
->
u
.
Status
=
STATUS_INVALID_PARAMETER_3
;
break
;
...
...
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