Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
35d202fc
Commit
35d202fc
authored
Apr 05, 2019
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Validate handle before freeing a LOAD_LIBRARY_AS_DATAFILE module.
Wine-Bug:
https://bugs.winehq.org/show_bug.cgi?id=46019
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
f2deab41
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
1 deletion
+12
-1
module.c
dlls/kernel32/module.c
+7
-1
module.c
dlls/kernel32/tests/module.c
+5
-0
No files found.
dlls/kernel32/module.c
View file @
35d202fc
...
...
@@ -1102,6 +1102,12 @@ BOOL WINAPI DECLSPEC_HOTPATCH FreeLibrary(HINSTANCE hLibModule)
if
((
ULONG_PTR
)
hLibModule
&
3
)
/* this is a datafile module */
{
void
*
ptr
=
(
void
*
)((
ULONG_PTR
)
hLibModule
&
~
3
);
if
(
!
RtlImageNtHeader
(
ptr
))
{
SetLastError
(
ERROR_BAD_EXE_FORMAT
);
return
FALSE
;
}
if
((
ULONG_PTR
)
hLibModule
&
1
)
{
struct
exclusive_datafile
*
file
;
...
...
@@ -1119,7 +1125,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH FreeLibrary(HINSTANCE hLibModule)
}
LdrUnlockLoaderLock
(
0
,
magic
);
}
return
UnmapViewOfFile
(
(
void
*
)((
ULONG_PTR
)
hLibModule
&
~
3
)
);
return
UnmapViewOfFile
(
ptr
);
}
if
((
nts
=
LdrUnloadDll
(
hLibModule
))
==
STATUS_SUCCESS
)
retv
=
TRUE
;
...
...
dlls/kernel32/tests/module.c
View file @
35d202fc
...
...
@@ -430,6 +430,11 @@ static void testLoadLibraryEx(void)
ok
(
hmodule
!=
0
,
"Expected valid module handle
\n
"
);
SetLastError
(
0xdeadbeef
);
ret
=
FreeLibrary
(
(
HMODULE
)((
ULONG_PTR
)
hmodule
+
0x1230
));
ok
(
!
ret
,
"Free succeeded on wrong handle
\n
"
);
ok
(
GetLastError
()
==
ERROR_BAD_EXE_FORMAT
,
"wrong error %u
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
ret
=
FreeLibrary
(
hmodule
);
ok
(
ret
,
"Expected to be able to free the module, failed with %d
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
...
...
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