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
Felix Münchhalfen
wine
Commits
b111b6d2
Commit
b111b6d2
authored
24 years ago
by
Guy Albertelli
Committed by
Alexandre Julliard
24 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Validate access even if wrap past address 0 for IsBadStringPtr[A|W]
and IsBad[Read|Write]Ptr.
parent
1563abe8
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
memory/virtual.c
+20
-14
20 additions, 14 deletions
memory/virtual.c
with
20 additions
and
14 deletions
memory/virtual.c
+
20
−
14
View file @
b111b6d2
...
...
@@ -85,9 +85,11 @@ static CRITICAL_SECTION csVirtual = CRITICAL_SECTION_INIT;
/* These are always the same on an i386, and it will be faster this way */
# define page_mask 0xfff
# define page_shift 12
# define page_size 0x1000
#else
static
UINT
page_shift
;
static
UINT
page_mask
;
static
UINT
page_size
;
#endif
/* __i386__ */
#define granularity_mask 0xffff
/* Allocation granularity (usually 64k) */
...
...
@@ -578,8 +580,6 @@ static LPVOID map_image( HANDLE hmapping, int fd, char *base, DWORD total_size,
#ifndef page_mask
DECL_GLOBAL_CONSTRUCTOR
(
VIRTUAL_Init
)
{
DWORD
page_size
;
# ifdef HAVE_GETPAGESIZE
page_size
=
getpagesize
();
# else
...
...
@@ -1163,18 +1163,21 @@ BOOL WINAPI IsBadReadPtr(
LPCVOID
ptr
,
/* Address of memory block */
UINT
size
)
/* Size of block */
{
if
(
!
size
)
return
FALSE
;
/* handle 0 size case w/o reference */
__TRY
{
volatile
const
char
*
p
=
ptr
;
volatile
const
char
*
end
=
p
+
size
-
1
;
char
dummy
;
UINT
count
=
size
;
while
(
p
<
end
)
while
(
count
>
page_size
)
{
dummy
=
*
p
;
p
+=
page_mask
+
1
;
p
+=
page_size
;
count
-=
page_size
;
}
dummy
=
*
end
;
dummy
=
p
[
0
];
dummy
=
p
[
count
-
1
];
}
__EXCEPT
(
page_fault
)
{
return
TRUE
;
}
__ENDTRY
...
...
@@ -1193,17 +1196,20 @@ BOOL WINAPI IsBadWritePtr(
LPVOID
ptr
,
/* [in] Address of memory block */
UINT
size
)
/* [in] Size of block in bytes */
{
if
(
!
size
)
return
FALSE
;
/* handle 0 size case w/o reference */
__TRY
{
volatile
char
*
p
=
ptr
;
volatile
char
*
end
=
p
+
size
-
1
;
UINT
count
=
size
;
while
(
p
<
end
)
while
(
count
>
page_size
)
{
*
p
|=
0
;
p
+=
page_mask
+
1
;
p
+=
page_size
;
count
-=
page_size
;
}
*
end
|=
0
;
p
[
0
]
|=
0
;
p
[
count
-
1
]
|=
0
;
}
__EXCEPT
(
page_fault
)
{
return
TRUE
;
}
__ENDTRY
...
...
@@ -1266,7 +1272,7 @@ BOOL WINAPI IsBadStringPtrA(
__TRY
{
volatile
const
char
*
p
=
str
;
while
(
p
<
str
+
max
)
if
(
!*
p
++
)
break
;
while
(
p
!=
str
+
max
)
if
(
!*
p
++
)
break
;
}
__EXCEPT
(
page_fault
)
{
return
TRUE
;
}
__ENDTRY
...
...
@@ -1283,7 +1289,7 @@ BOOL WINAPI IsBadStringPtrW( LPCWSTR str, UINT max )
__TRY
{
volatile
const
WCHAR
*
p
=
str
;
while
(
p
<
str
+
max
)
if
(
!*
p
++
)
break
;
while
(
p
!=
str
+
max
)
if
(
!*
p
++
)
break
;
}
__EXCEPT
(
page_fault
)
{
return
TRUE
;
}
__ENDTRY
...
...
@@ -1301,7 +1307,7 @@ BOOL WINAPI IsBadStringPtrW( LPCWSTR str, UINT max )
* NULL: Failure
*/
HANDLE
WINAPI
CreateFileMappingA
(
H
FI
LE
hFile
,
/* [in] Handle of file to map */
H
AND
LE
hFile
,
/* [in] Handle of file to map */
SECURITY_ATTRIBUTES
*
sa
,
/* [in] Optional security attributes*/
DWORD
protect
,
/* [in] Protection for mapping object */
DWORD
size_high
,
/* [in] High-order 32 bits of object size */
...
...
@@ -1361,7 +1367,7 @@ HANDLE WINAPI CreateFileMappingA(
* CreateFileMappingW (KERNEL32.47)
* See CreateFileMappingA
*/
HANDLE
WINAPI
CreateFileMappingW
(
H
FI
LE
hFile
,
LPSECURITY_ATTRIBUTES
sa
,
HANDLE
WINAPI
CreateFileMappingW
(
H
AND
LE
hFile
,
LPSECURITY_ATTRIBUTES
sa
,
DWORD
protect
,
DWORD
size_high
,
DWORD
size_low
,
LPCWSTR
name
)
{
...
...
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