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
f435914b
Commit
f435914b
authored
Jun 15, 2004
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added magic number in the FindFirstFile structure to allow more robust
detection of bad handles (with help from Aric Stewart).
parent
cc461324
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
17 deletions
+33
-17
file.c
dlls/kernel/file.c
+33
-17
No files found.
dlls/kernel/file.c
View file @
f435914b
...
...
@@ -51,6 +51,7 @@ HANDLE dos_handles[DOS_TABLE_SIZE];
/* info structure for FindFirstFile handle */
typedef
struct
{
DWORD
magic
;
/* magic number */
HANDLE
handle
;
/* handle to directory */
CRITICAL_SECTION
cs
;
/* crit section protecting this structure */
UNICODE_STRING
mask
;
/* file mask */
...
...
@@ -60,6 +61,8 @@ typedef struct
BYTE
data
[
8192
];
/* directory data */
}
FIND_FIRST_INFO
;
#define FIND_FIRST_MAGIC 0xc0ffee11
static
BOOL
oem_file_apis
;
static
WINE_EXCEPTION_FILTER
(
page_fault
)
...
...
@@ -1489,6 +1492,7 @@ HANDLE WINAPI FindFirstFileExW( LPCWSTR filename, FINDEX_INFO_LEVELS level,
RtlFreeUnicodeString
(
&
nt_name
);
RtlInitializeCriticalSection
(
&
info
->
cs
);
info
->
magic
=
FIND_FIRST_MAGIC
;
info
->
data_pos
=
0
;
info
->
data_len
=
0
;
...
...
@@ -1518,13 +1522,18 @@ BOOL WINAPI FindNextFileW( HANDLE handle, WIN32_FIND_DATAW *data )
BOOL
ret
=
FALSE
;
TRACE
(
"%p %p
\n
"
,
handle
,
data
);
if
(
handle
==
INVALID_HANDLE_VALUE
)
if
(
!
handle
||
handle
==
INVALID_HANDLE_VALUE
)
{
SetLastError
(
ERROR_INVALID_HANDLE
);
return
ret
;
}
info
=
(
FIND_FIRST_INFO
*
)
handle
;
if
(
info
->
magic
!=
FIND_FIRST_MAGIC
)
{
SetLastError
(
ERROR_INVALID_HANDLE
);
return
ret
;
}
RtlEnterCriticalSection
(
&
info
->
cs
);
...
...
@@ -1591,17 +1600,31 @@ BOOL WINAPI FindClose( HANDLE handle )
{
FIND_FIRST_INFO
*
info
=
(
FIND_FIRST_INFO
*
)
handle
;
if
(
!
handle
||
handle
==
INVALID_HANDLE_VALUE
)
goto
error
;
if
(
!
handle
||
handle
==
INVALID_HANDLE_VALUE
)
{
SetLastError
(
ERROR_INVALID_HANDLE
);
return
FALSE
;
}
__TRY
{
RtlEnterCriticalSection
(
&
info
->
cs
);
if
(
info
->
handle
)
CloseHandle
(
info
->
handle
);
info
->
handle
=
0
;
RtlFreeUnicodeString
(
&
info
->
mask
);
info
->
mask
.
Buffer
=
NULL
;
info
->
data_pos
=
0
;
info
->
data_len
=
0
;
if
(
info
->
magic
==
FIND_FIRST_MAGIC
)
{
RtlEnterCriticalSection
(
&
info
->
cs
);
if
(
info
->
magic
==
FIND_FIRST_MAGIC
)
/* in case someone else freed it in the meantime */
{
info
->
magic
=
0
;
if
(
info
->
handle
)
CloseHandle
(
info
->
handle
);
info
->
handle
=
0
;
RtlFreeUnicodeString
(
&
info
->
mask
);
info
->
mask
.
Buffer
=
NULL
;
info
->
data_pos
=
0
;
info
->
data_len
=
0
;
RtlLeaveCriticalSection
(
&
info
->
cs
);
RtlDeleteCriticalSection
(
&
info
->
cs
);
HeapFree
(
GetProcessHeap
(),
0
,
info
);
}
}
}
__EXCEPT
(
page_fault
)
{
...
...
@@ -1611,14 +1634,7 @@ BOOL WINAPI FindClose( HANDLE handle )
}
__ENDTRY
RtlLeaveCriticalSection
(
&
info
->
cs
);
RtlDeleteCriticalSection
(
&
info
->
cs
);
HeapFree
(
GetProcessHeap
(),
0
,
info
);
return
TRUE
;
error:
SetLastError
(
ERROR_INVALID_HANDLE
);
return
FALSE
;
}
...
...
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