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
46182aa5
Commit
46182aa5
authored
Jul 24, 2020
by
Zhiyi Zhang
Committed by
Alexandre Julliard
Jul 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user32: Check invalid device names in EnumDisplaySettingsExW().
Signed-off-by:
Zhiyi Zhang
<
zzhang@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
8928a417
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
14 deletions
+27
-14
sysparams.c
dlls/user32/sysparams.c
+23
-10
sysparams.c
dlls/user32/tests/sysparams.c
+4
-4
No files found.
dlls/user32/sysparams.c
View file @
46182aa5
...
...
@@ -590,6 +590,21 @@ static BOOL get_primary_adapter(WCHAR *name)
return
FALSE
;
}
static
BOOL
is_valid_adapter_name
(
const
WCHAR
*
name
)
{
long
int
adapter_idx
;
WCHAR
*
end
;
if
(
strncmpiW
(
name
,
ADAPTER_PREFIX
,
ARRAY_SIZE
(
ADAPTER_PREFIX
)))
return
FALSE
;
adapter_idx
=
strtolW
(
name
+
ARRAY_SIZE
(
ADAPTER_PREFIX
),
&
end
,
10
);
if
(
*
end
||
adapter_idx
<
1
)
return
FALSE
;
return
TRUE
;
}
/* get text metrics and/or "average" char width of the specified logfont
* for the specified dc */
static
void
get_text_metr_size
(
HDC
hdc
,
LOGFONTW
*
plf
,
TEXTMETRICW
*
ptm
,
UINT
*
psz
)
...
...
@@ -3307,8 +3322,7 @@ static BOOL is_detached_mode(const DEVMODEW *mode)
LONG
WINAPI
ChangeDisplaySettingsExW
(
LPCWSTR
devname
,
LPDEVMODEW
devmode
,
HWND
hwnd
,
DWORD
flags
,
LPVOID
lparam
)
{
WCHAR
primary_adapter
[
CCHDEVICENAME
],
*
end
;
long
int
display_idx
;
WCHAR
primary_adapter
[
CCHDEVICENAME
];
BOOL
def_mode
=
TRUE
;
DEVMODEW
dm
;
LONG
ret
;
...
...
@@ -3332,14 +3346,7 @@ LONG WINAPI ChangeDisplaySettingsExW( LPCWSTR devname, LPDEVMODEW devmode, HWND
devname
=
primary_adapter
;
}
if
(
strncmpiW
(
devname
,
ADAPTER_PREFIX
,
ARRAY_SIZE
(
ADAPTER_PREFIX
)))
{
ERR
(
"Invalid device name %s.
\n
"
,
wine_dbgstr_w
(
devname
));
return
DISP_CHANGE_BADPARAM
;
}
display_idx
=
strtolW
(
devname
+
ARRAY_SIZE
(
ADAPTER_PREFIX
),
&
end
,
10
);
if
(
*
end
||
display_idx
<
1
)
if
(
!
is_valid_adapter_name
(
devname
))
{
ERR
(
"Invalid device name %s.
\n
"
,
wine_dbgstr_w
(
devname
));
return
DISP_CHANGE_BADPARAM
;
...
...
@@ -3466,6 +3473,12 @@ BOOL WINAPI EnumDisplaySettingsExW(LPCWSTR lpszDeviceName, DWORD iModeNum,
lpszDeviceName
=
primary_adapter
;
}
if
(
!
is_valid_adapter_name
(
lpszDeviceName
))
{
ERR
(
"Invalid device name %s.
\n
"
,
wine_dbgstr_w
(
lpszDeviceName
));
return
FALSE
;
}
ret
=
USER_Driver
->
pEnumDisplaySettingsEx
(
lpszDeviceName
,
iModeNum
,
lpDevMode
,
dwFlags
);
if
(
ret
)
TRACE
(
"device:%s mode index:%#x position:(%d,%d) resolution:%ux%u frequency:%uHz "
...
...
dlls/user32/tests/sysparams.c
View file @
46182aa5
...
...
@@ -3154,18 +3154,18 @@ static void test_EnumDisplaySettings(void)
dm
.
dmSize
=
sizeof
(
dm
);
SetLastError
(
0xdeadbeef
);
ret
=
EnumDisplaySettingsA
(
"invalid"
,
ENUM_CURRENT_SETTINGS
,
&
dm
);
todo_wine
ok
(
!
ret
,
"EnumDisplaySettingsA succeeded
\n
"
);
ok
(
!
ret
,
"EnumDisplaySettingsA succeeded
\n
"
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"Expect error 0xdeadbeef, got %#x
\n
"
,
GetLastError
());
todo_wine
ok
(
dm
.
dmFields
==
0
,
"Expect dmFields unchanged, got %#x
\n
"
,
dm
.
dmFields
);
ok
(
dm
.
dmFields
==
0
,
"Expect dmFields unchanged, got %#x
\n
"
,
dm
.
dmFields
);
/* Monitor device names are invalid */
memset
(
&
dm
,
0
,
sizeof
(
dm
));
dm
.
dmSize
=
sizeof
(
dm
);
SetLastError
(
0xdeadbeef
);
ret
=
EnumDisplaySettingsA
(
"
\\\\
.
\\
DISPLAY1
\\
Monitor0"
,
ENUM_CURRENT_SETTINGS
,
&
dm
);
todo_wine
ok
(
!
ret
,
"EnumDisplaySettingsA succeeded
\n
"
);
ok
(
!
ret
,
"EnumDisplaySettingsA succeeded
\n
"
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"Expect error 0xdeadbeef, got %#x
\n
"
,
GetLastError
());
todo_wine
ok
(
dm
.
dmFields
==
0
,
"Expect dmFields unchanged, got %#x
\n
"
,
dm
.
dmFields
);
ok
(
dm
.
dmFields
==
0
,
"Expect dmFields unchanged, got %#x
\n
"
,
dm
.
dmFields
);
/* Test that passing NULL to device name parameter means to use the primary adapter */
memset
(
&
dm
,
0
,
sizeof
(
dm
));
...
...
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