Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Johnny Cai
wine
Commits
034e39b2
Commit
034e39b2
authored
22 years ago
by
Alexandre Julliard
Browse files
Options
Downloads
Patches
Plain Diff
Check access rights before renaming or deleting files (based on
patches by Uwe Bonnes and Dmitry Timoshkov).
parent
ccab2877
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dlls/kernel/tests/file.c
+5
-6
5 additions, 6 deletions
dlls/kernel/tests/file.c
files/file.c
+26
-0
26 additions, 0 deletions
files/file.c
with
31 additions
and
6 deletions
dlls/kernel/tests/file.c
+
5
−
6
View file @
034e39b2
...
...
@@ -49,6 +49,8 @@ static void test__hread( void )
long
bytes_wanted
;
UINT
i
;
SetFileAttributesA
(
filename
,
FILE_ATTRIBUTE_NORMAL
);
/* be sure to remove stale files */
DeleteFileA
(
filename
);
filehandle
=
_lcreat
(
filename
,
0
);
if
(
filehandle
==
HFILE_ERROR
)
{
...
...
@@ -224,14 +226,11 @@ static void test__lcreat( void )
ok
(
INVALID_HANDLE_VALUE
!=
FindFirstFileA
(
filename
,
&
search_results
),
"should be able to find file"
);
todo_wine
{
ok
(
0
==
DeleteFileA
(
filename
),
"shouldn't be able to delete a readonly file"
);
ok
(
0
==
DeleteFileA
(
filename
),
"shouldn't be able to delete a readonly file"
);
ok
(
SetFileAttributesA
(
filename
,
FILE_ATTRIBUTE_NORMAL
)
!=
0
,
"couldn't change attributes on file"
);
ok
(
SetFileAttributesA
(
filename
,
FILE_ATTRIBUTE_NORMAL
)
!=
0
,
"couldn't change attributes on file"
);
ok
(
DeleteFileA
(
filename
)
!=
0
,
"now it should be possible to delete the file!"
);
}
ok
(
DeleteFileA
(
filename
)
!=
0
,
"now it should be possible to delete the file!"
);
filehandle
=
_lcreat
(
filename
,
2
);
ok
(
HFILE_ERROR
!=
filehandle
,
"couldn't create file
\"
%s
\"
(err=%d)"
,
filename
,
GetLastError
(
)
);
...
...
This diff is collapsed.
Click to expand it.
files/file.c
+
26
−
0
View file @
034e39b2
...
...
@@ -2149,6 +2149,7 @@ BOOL16 WINAPI DeleteFile16( LPCSTR path )
BOOL
WINAPI
DeleteFileA
(
LPCSTR
path
)
{
DOS_FULL_NAME
full_name
;
HANDLE
hFile
;
if
(
!
path
)
{
...
...
@@ -2170,11 +2171,20 @@ BOOL WINAPI DeleteFileA( LPCSTR path )
}
if
(
!
DOSFS_GetFullName
(
path
,
TRUE
,
&
full_name
))
return
FALSE
;
/* check if we are allowed to delete the source */
hFile
=
FILE_CreateFile
(
full_name
.
long_name
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
0
,
TRUE
,
GetDriveTypeA
(
full_name
.
short_name
)
);
if
(
!
hFile
)
return
FALSE
;
if
(
unlink
(
full_name
.
long_name
)
==
-
1
)
{
FILE_SetDosError
();
CloseHandle
(
hFile
);
return
FALSE
;
}
CloseHandle
(
hFile
);
return
TRUE
;
}
...
...
@@ -2317,6 +2327,7 @@ static BOOL FILE_AddBootRenameEntry( const char *fn1, const char *fn2, DWORD fla
BOOL
WINAPI
MoveFileExA
(
LPCSTR
fn1
,
LPCSTR
fn2
,
DWORD
flag
)
{
DOS_FULL_NAME
full_name1
,
full_name2
;
HANDLE
hFile
;
TRACE
(
"(%s,%s,%04lx)
\n
"
,
fn1
,
fn2
,
flag
);
...
...
@@ -2385,6 +2396,21 @@ BOOL WINAPI MoveFileExA( LPCSTR fn1, LPCSTR fn2, DWORD flag )
return
FILE_AddBootRenameEntry
(
fn1
,
fn2
,
flag
);
}
/* check if we are allowed to delete the source */
hFile
=
FILE_CreateFile
(
full_name1
.
long_name
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
0
,
TRUE
,
GetDriveTypeA
(
full_name1
.
short_name
)
);
if
(
!
hFile
)
return
FALSE
;
CloseHandle
(
hFile
);
/* check, if we are allowed to delete the destination,
** (but the file not being there is fine) */
hFile
=
FILE_CreateFile
(
full_name2
.
long_name
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
0
,
TRUE
,
GetDriveTypeA
(
full_name2
.
short_name
)
);
if
(
!
hFile
&&
GetLastError
()
!=
ERROR_FILE_NOT_FOUND
)
return
FALSE
;
CloseHandle
(
hFile
);
if
(
full_name1
.
drive
!=
full_name2
.
drive
)
{
/* use copy, if allowed */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment