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
284f8618
Commit
284f8618
authored
Feb 21, 2008
by
Maarten Lankhorst
Committed by
Alexandre Julliard
Feb 22, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
advapi: Check if service really exists before bombing out in CreateService.
parent
0b3d880c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
15 deletions
+12
-15
service.c
dlls/advapi32/service.c
+12
-15
No files found.
dlls/advapi32/service.c
View file @
284f8618
...
@@ -1302,19 +1302,9 @@ CreateServiceW( SC_HANDLE hSCManager, LPCWSTR lpServiceName,
...
@@ -1302,19 +1302,9 @@ CreateServiceW( SC_HANDLE hSCManager, LPCWSTR lpServiceName,
{
{
HKEY
service_key
;
HKEY
service_key
;
/* The service already exists, so bail out */
/* Open service first before deciding whether it already exists or not
if
(
!
lstrcmpiW
(
lpServiceName
,
buffer
))
* It could be that it's not a valid service, but only the registry key itself exists
{
SetLastError
(
ERROR_SERVICE_EXISTS
);
return
NULL
;
}
/* The given displayname matches the found servicename. We don't bail out
* as servicename is checked before a duplicate displayname
*/
*/
if
(
!
lstrcmpiW
(
lpDisplayName
,
buffer
))
displayname_exists
=
TRUE
;
if
(
RegOpenKeyExW
(
hscm
->
hkey
,
buffer
,
0
,
KEY_READ
,
&
service_key
)
==
ERROR_SUCCESS
)
if
(
RegOpenKeyExW
(
hscm
->
hkey
,
buffer
,
0
,
KEY_READ
,
&
service_key
)
==
ERROR_SUCCESS
)
{
{
WCHAR
name
[
MAX_PATH
];
WCHAR
name
[
MAX_PATH
];
...
@@ -1322,9 +1312,16 @@ CreateServiceW( SC_HANDLE hSCManager, LPCWSTR lpServiceName,
...
@@ -1322,9 +1312,16 @@ CreateServiceW( SC_HANDLE hSCManager, LPCWSTR lpServiceName,
if
(
RegQueryValueExW
(
service_key
,
szDisplayName
,
NULL
,
NULL
,
(
LPBYTE
)
name
,
&
size
)
==
ERROR_SUCCESS
)
if
(
RegQueryValueExW
(
service_key
,
szDisplayName
,
NULL
,
NULL
,
(
LPBYTE
)
name
,
&
size
)
==
ERROR_SUCCESS
)
{
{
/* The given displayname matches the found displayname */
if
(
lpDisplayName
&&
(
!
lstrcmpiW
(
lpDisplayName
,
name
)
if
(
!
lstrcmpiW
(
lpDisplayName
,
name
))
||
!
lstrcmpiW
(
lpDisplayName
,
buffer
)
))
displayname_exists
=
TRUE
;
displayname_exists
=
TRUE
;
if
(
!
lstrcmpiW
(
lpServiceName
,
buffer
))
{
RegCloseKey
(
service_key
);
SetLastError
(
ERROR_SERVICE_EXISTS
);
return
NULL
;
}
}
}
RegCloseKey
(
service_key
);
RegCloseKey
(
service_key
);
}
}
...
@@ -1332,7 +1329,7 @@ CreateServiceW( SC_HANDLE hSCManager, LPCWSTR lpServiceName,
...
@@ -1332,7 +1329,7 @@ CreateServiceW( SC_HANDLE hSCManager, LPCWSTR lpServiceName,
len
=
sizeof
(
buffer
);
len
=
sizeof
(
buffer
);
}
}
if
(
lpDisplayName
&&
displayname_exists
)
if
(
displayname_exists
)
{
{
SetLastError
(
ERROR_DUPLICATE_SERVICE_NAME
);
SetLastError
(
ERROR_DUPLICATE_SERVICE_NAME
);
return
NULL
;
return
NULL
;
...
...
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