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
3eb06cf4
Commit
3eb06cf4
authored
Nov 25, 2022
by
Tingzhong Luo
Committed by
Alexandre Julliard
Feb 27, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winspool: Check dmSize in IsValidDevmodeW().
parent
9d6a9909
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
2 deletions
+35
-2
info.c
dlls/winspool.drv/info.c
+4
-2
info.c
dlls/winspool.drv/tests/info.c
+31
-0
No files found.
dlls/winspool.drv/info.c
View file @
3eb06cf4
...
...
@@ -1927,12 +1927,14 @@ BOOL WINAPI IsValidDevmodeW(PDEVMODEW dm, SIZE_T size)
#undef F_SIZE
};
int
i
;
const
DWORD
fields_off
=
FIELD_OFFSET
(
DEVMODEW
,
dmFields
)
+
sizeof
(
dm
->
dmFields
);
if
(
!
dm
)
return
FALSE
;
if
(
size
<
FIELD_OFFSET
(
DEVMODEW
,
dmFields
)
+
sizeof
(
dm
->
dmFields
))
return
FALSE
;
if
(
size
<
fields_off
)
return
FALSE
;
if
(
dm
->
dmSize
<
fields_off
||
size
<
dm
->
dmSize
+
dm
->
dmDriverExtra
)
return
FALSE
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
map
);
i
++
)
if
((
dm
->
dmFields
&
map
[
i
].
flag
)
&&
s
ize
<
map
[
i
].
size
)
if
((
dm
->
dmFields
&
map
[
i
].
flag
)
&&
dm
->
dmS
ize
<
map
[
i
].
size
)
return
FALSE
;
return
TRUE
;
...
...
dlls/winspool.drv/tests/info.c
View file @
3eb06cf4
...
...
@@ -3046,6 +3046,26 @@ static void test_IsValidDevmodeW(void)
{
DM_NUP
,
FIELD_OFFSET
(
DEVMODEW
,
u2
.
dmNup
)
+
4
,
TRUE
},
};
static
const
struct
{
DWORD
dmSize
;
DWORD
dmDriverExtra
;
DWORD
bufSize
;
BOOL
ret
;
}
size_test
[]
=
{
{
FIELD_OFFSET
(
DEVMODEW
,
dmFields
)
+
3
,
1
,
FIELD_OFFSET
(
DEVMODEW
,
dmFields
)
+
4
,
FALSE
},
{
FIELD_OFFSET
(
DEVMODEW
,
dmFields
)
+
4
,
1
,
FIELD_OFFSET
(
DEVMODEW
,
dmFields
)
+
8
,
TRUE
},
{
FIELD_OFFSET
(
DEVMODEW
,
dmFields
)
+
4
,
2
,
FIELD_OFFSET
(
DEVMODEW
,
dmFields
)
+
8
,
TRUE
},
{
FIELD_OFFSET
(
DEVMODEW
,
dmFields
)
+
4
,
3
,
FIELD_OFFSET
(
DEVMODEW
,
dmFields
)
+
8
,
TRUE
},
{
FIELD_OFFSET
(
DEVMODEW
,
dmFields
)
+
4
,
4
,
FIELD_OFFSET
(
DEVMODEW
,
dmFields
)
+
8
,
TRUE
},
{
FIELD_OFFSET
(
DEVMODEW
,
dmFields
)
+
4
,
5
,
FIELD_OFFSET
(
DEVMODEW
,
dmFields
)
+
8
,
FALSE
},
{
FIELD_OFFSET
(
DEVMODEW
,
dmFields
)
+
12
,
1
,
FIELD_OFFSET
(
DEVMODEW
,
dmFields
)
+
16
,
TRUE
},
{
FIELD_OFFSET
(
DEVMODEW
,
dmFields
)
+
12
,
2
,
FIELD_OFFSET
(
DEVMODEW
,
dmFields
)
+
16
,
TRUE
},
{
FIELD_OFFSET
(
DEVMODEW
,
dmFields
)
+
12
,
3
,
FIELD_OFFSET
(
DEVMODEW
,
dmFields
)
+
16
,
TRUE
},
{
FIELD_OFFSET
(
DEVMODEW
,
dmFields
)
+
12
,
4
,
FIELD_OFFSET
(
DEVMODEW
,
dmFields
)
+
16
,
TRUE
},
{
FIELD_OFFSET
(
DEVMODEW
,
dmFields
)
+
12
,
5
,
FIELD_OFFSET
(
DEVMODEW
,
dmFields
)
+
16
,
FALSE
},
};
DEVMODEW
dm
;
int
i
;
BOOL
ret
;
...
...
@@ -3064,6 +3084,17 @@ static void test_IsValidDevmodeW(void)
dm
.
dmFields
=
test
[
i
].
dmFields
;
ret
=
IsValidDevmodeW
(
&
dm
,
dm
.
dmSize
);
ok
(
ret
==
test
[
i
].
ret
,
"%d: got %d
\n
"
,
i
,
ret
);
ret
=
IsValidDevmodeW
(
&
dm
,
dm
.
dmSize
+
4
);
ok
(
ret
==
test
[
i
].
ret
,
"%d: got %d
\n
"
,
i
,
ret
);
}
dm
.
dmFields
=
0
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
size_test
);
i
++
)
{
dm
.
dmSize
=
size_test
[
i
].
dmSize
;
dm
.
dmDriverExtra
=
size_test
[
i
].
dmDriverExtra
;
ret
=
IsValidDevmodeW
(
&
dm
,
size_test
[
i
].
bufSize
);
ok
(
ret
==
size_test
[
i
].
ret
,
"%d: got %d
\n
"
,
i
,
ret
);
}
}
...
...
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