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
8289c651
Commit
8289c651
authored
Nov 27, 2018
by
Zebediah Figura
Committed by
Alexandre Julliard
Nov 28, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
setupapi: Enforce a maximum device instance ID length.
Signed-off-by:
Zebediah Figura
<
z.figura12@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
c00a322d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
6 deletions
+28
-6
devinst.c
dlls/setupapi/devinst.c
+9
-5
devinst.c
dlls/setupapi/tests/devinst.c
+19
-1
No files found.
dlls/setupapi/devinst.c
View file @
8289c651
...
...
@@ -1337,7 +1337,7 @@ HKEY WINAPI SetupDiCreateDevRegKeyW(HDEVINFO devinfo, SP_DEVINFO_DATA *device_da
/***********************************************************************
* SetupDiCreateDeviceInfoA (SETUPAPI.@)
*/
BOOL
WINAPI
SetupDiCreateDeviceInfoA
(
HDEVINFO
DeviceInfoSet
,
PCSTR
DeviceN
ame
,
BOOL
WINAPI
SetupDiCreateDeviceInfoA
(
HDEVINFO
DeviceInfoSet
,
const
char
*
n
ame
,
const
GUID
*
ClassGuid
,
PCSTR
DeviceDescription
,
HWND
hwndParent
,
DWORD
CreationFlags
,
PSP_DEVINFO_DATA
DeviceInfoData
)
{
...
...
@@ -1345,11 +1345,15 @@ BOOL WINAPI SetupDiCreateDeviceInfoA(HDEVINFO DeviceInfoSet, PCSTR DeviceName,
LPWSTR
DeviceNameW
=
NULL
;
LPWSTR
DeviceDescriptionW
=
NULL
;
if
(
DeviceName
)
if
(
!
name
||
strlen
(
name
)
>=
MAX_DEVICE_ID_LEN
)
{
DeviceNameW
=
MultiByteToUnicode
(
DeviceName
,
CP_ACP
);
if
(
DeviceNameW
==
NULL
)
return
FALSE
;
SetLastError
(
ERROR_INVALID_DEVINST_NAME
);
return
FALSE
;
}
DeviceNameW
=
MultiByteToUnicode
(
name
,
CP_ACP
);
if
(
DeviceNameW
==
NULL
)
return
FALSE
;
if
(
DeviceDescription
)
{
DeviceDescriptionW
=
MultiByteToUnicode
(
DeviceDescription
,
CP_ACP
);
...
...
@@ -1407,7 +1411,7 @@ BOOL WINAPI SetupDiCreateDeviceInfoW(HDEVINFO devinfo, PCWSTR DeviceName,
devinfo
,
debugstr_w
(
DeviceName
),
debugstr_guid
(
ClassGuid
),
debugstr_w
(
DeviceDescription
),
hwndParent
,
CreationFlags
,
device_data
);
if
(
!
DeviceName
)
if
(
!
DeviceName
||
strlenW
(
DeviceName
)
>=
MAX_DEVICE_ID_LEN
)
{
SetLastError
(
ERROR_INVALID_DEVINST_NAME
);
return
FALSE
;
...
...
dlls/setupapi/tests/devinst.c
View file @
8289c651
...
...
@@ -271,8 +271,8 @@ static void test_device_info(void)
{
static
const
GUID
deadbeef
=
{
0xdeadbeef
,
0xdead
,
0xbeef
,{
0xde
,
0xad
,
0xbe
,
0xef
,
0xde
,
0xad
,
0xbe
,
0xef
}};
SP_DEVINFO_DATA
device
=
{
0
},
ret_device
=
{
sizeof
(
ret_device
)};
char
id
[
MAX_DEVICE_ID_LEN
+
2
];
HDEVINFO
set
;
char
id
[
50
];
BOOL
ret
;
SetLastError
(
0xdeadbeef
);
...
...
@@ -382,6 +382,24 @@ todo_wine {
check_device_info
(
set
,
2
,
&
guid
,
"ROOT
\\
LEGACY_BOGUS
\\
testguid"
);
check_device_info
(
set
,
3
,
NULL
,
NULL
);
memset
(
id
,
'x'
,
sizeof
(
id
));
memcpy
(
id
,
"Root
\\
LEGACY_BOGUS
\\
"
,
strlen
(
"Root
\\
LEGACY_BOGUS
\\
"
));
id
[
MAX_DEVICE_ID_LEN
+
1
]
=
0
;
SetLastError
(
0xdeadbeef
);
ret
=
SetupDiCreateDeviceInfoA
(
set
,
id
,
&
guid
,
NULL
,
NULL
,
0
,
NULL
);
ok
(
!
ret
,
"Expected failure.
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_DEVINST_NAME
,
"Got unexpected error %#x.
\n
"
,
GetLastError
());
id
[
MAX_DEVICE_ID_LEN
]
=
0
;
SetLastError
(
0xdeadbeef
);
ret
=
SetupDiCreateDeviceInfoA
(
set
,
id
,
&
guid
,
NULL
,
NULL
,
0
,
NULL
);
ok
(
!
ret
,
"Expected failure.
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_DEVINST_NAME
,
"Got unexpected error %#x.
\n
"
,
GetLastError
());
id
[
MAX_DEVICE_ID_LEN
-
1
]
=
0
;
ret
=
SetupDiCreateDeviceInfoA
(
set
,
id
,
&
guid
,
NULL
,
NULL
,
0
,
NULL
);
ok
(
ret
,
"Failed to create device, error %#x.
\n
"
,
GetLastError
());
SetupDiDestroyDeviceInfoList
(
set
);
}
...
...
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