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
137eb037
Commit
137eb037
authored
Jul 11, 2007
by
Paul Vriens
Committed by
Alexandre Julliard
Jul 12, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
advapi/service: Check for empty servicename and binaryname.
parent
c011369a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
0 deletions
+44
-0
service.c
dlls/advapi32/service.c
+12
-0
service.c
dlls/advapi32/tests/service.c
+32
-0
No files found.
dlls/advapi32/service.c
View file @
137eb037
...
...
@@ -1321,6 +1321,18 @@ CreateServiceW( SC_HANDLE hSCManager, LPCWSTR lpServiceName,
return
NULL
;
}
if
(
!
lpServiceName
[
0
])
{
SetLastError
(
ERROR_INVALID_NAME
);
return
NULL
;
}
if
(
!
lpBinaryPathName
[
0
])
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
NULL
;
}
r
=
RegCreateKeyExW
(
hscm
->
hkey
,
lpServiceName
,
0
,
NULL
,
REG_OPTION_NON_VOLATILE
,
KEY_ALL_ACCESS
,
NULL
,
&
hKey
,
&
dp
);
if
(
r
!=
ERROR_SUCCESS
)
...
...
dlls/advapi32/tests/service.c
View file @
137eb037
...
...
@@ -188,6 +188,38 @@ static void test_create_delete_svc(void)
ok
(
!
svc_handle1
,
"Expected failure
\n
"
);
ok
(
GetLastError
()
==
ERROR_ACCESS_DENIED
,
"Expected ERROR_ACCESS_DENIED, got %d
\n
"
,
GetLastError
());
/* Open the Service Control Manager with minimal rights for creation (verified with 'SC_MANAGER_ALL_ACCESS &~ SC_MANAGER_CREATE_SERVICE') */
CloseServiceHandle
(
scm_handle
);
SetLastError
(
0xdeadbeef
);
scm_handle
=
OpenSCManagerA
(
NULL
,
NULL
,
SC_MANAGER_CREATE_SERVICE
);
if
(
!
scm_handle
&&
(
GetLastError
()
==
ERROR_ACCESS_DENIED
))
{
skip
(
"Not enough rights to get a handle to the manager
\n
"
);
return
;
}
/* Empty strings for servicename and binary name are checked */
SetLastError
(
0xdeadbeef
);
svc_handle1
=
CreateServiceA
(
scm_handle
,
empty
,
NULL
,
0
,
0
,
0
,
0
,
pathname
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
!
svc_handle1
,
"Expected failure
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_NAME
,
"Expected ERROR_INVALID_NAME, got %d
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
svc_handle1
=
CreateServiceA
(
scm_handle
,
servicename
,
NULL
,
0
,
0
,
0
,
0
,
empty
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
!
svc_handle1
,
"Expected failure
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"Expected ERROR_INVALID_PARAMETER, got %d
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
svc_handle1
=
CreateServiceA
(
scm_handle
,
empty
,
NULL
,
0
,
0
,
0
,
0
,
empty
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
!
svc_handle1
,
"Expected failure
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_NAME
,
"Expected ERROR_INVALID_NAME, got %d
\n
"
,
GetLastError
());
/* Valid call (as we will see later) except for the empty binary name (to proof it's indeed an ERROR_INVALID_PARAMETER */
SetLastError
(
0xdeadbeef
);
svc_handle1
=
CreateServiceA
(
scm_handle
,
servicename
,
NULL
,
0
,
SERVICE_WIN32_OWN_PROCESS
,
SERVICE_DISABLED
,
0
,
empty
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
!
svc_handle1
,
"Expected failure
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"Expected ERROR_INVALID_PARAMETER, got %d
\n
"
,
GetLastError
());
CloseServiceHandle
(
scm_handle
);
}
...
...
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