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
034e39b2
Commit
034e39b2
authored
Jun 05, 2002
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check access rights before renaming or deleting files (based on
patches by Uwe Bonnes and Dmitry Timoshkov).
parent
ccab2877
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
6 deletions
+31
-6
file.c
dlls/kernel/tests/file.c
+5
-6
file.c
files/file.c
+26
-0
No files found.
dlls/kernel/tests/file.c
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
(
)
);
...
...
files/file.c
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 */
...
...
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