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
519fbf62
Commit
519fbf62
authored
Jun 09, 2011
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
advapi32: Fix the parameter checks in QueryServiceStatusEx.
parent
a2f987c3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
16 deletions
+23
-16
service.c
dlls/advapi32/service.c
+17
-6
service.c
dlls/advapi32/tests/service.c
+6
-10
No files found.
dlls/advapi32/service.c
View file @
519fbf62
...
...
@@ -1172,21 +1172,32 @@ BOOL WINAPI QueryServiceStatusEx(SC_HANDLE hService, SC_STATUS_TYPE InfoLevel,
TRACE
(
"%p %d %p %d %p
\n
"
,
hService
,
InfoLevel
,
lpBuffer
,
cbBufSize
,
pcbBytesNeeded
);
__TRY
if
(
InfoLevel
!=
SC_STATUS_PROCESS_INFO
)
{
err
=
svcctl_QueryServiceStatusEx
(
hService
,
InfoLevel
,
lpBuffer
,
cbBufSize
,
pcbBytesNeeded
)
;
err
=
ERROR_INVALID_LEVEL
;
}
__EXCEPT
(
rpc_filter
)
else
if
(
cbBufSize
<
sizeof
(
SERVICE_STATUS_PROCESS
)
)
{
err
=
map_exception_code
(
GetExceptionCode
());
*
pcbBytesNeeded
=
sizeof
(
SERVICE_STATUS_PROCESS
);
err
=
ERROR_INSUFFICIENT_BUFFER
;
}
else
{
__TRY
{
err
=
svcctl_QueryServiceStatusEx
(
hService
,
InfoLevel
,
lpBuffer
,
cbBufSize
,
pcbBytesNeeded
);
}
__EXCEPT
(
rpc_filter
)
{
err
=
map_exception_code
(
GetExceptionCode
());
}
__ENDTRY
}
__ENDTRY
if
(
err
!=
ERROR_SUCCESS
)
{
SetLastError
(
err
);
return
FALSE
;
}
return
TRUE
;
}
...
...
dlls/advapi32/tests/service.c
View file @
519fbf62
...
...
@@ -956,7 +956,6 @@ static void test_query_svc(void)
SetLastError
(
0xdeadbeef
);
ret
=
pQueryServiceStatusEx
(
NULL
,
1
,
NULL
,
0
,
NULL
);
ok
(
!
ret
,
"Expected failure
\n
"
);
todo_wine
ok
(
GetLastError
()
==
ERROR_INVALID_LEVEL
,
"Expected ERROR_INVALID_LEVEL, got %d
\n
"
,
GetLastError
());
...
...
@@ -966,8 +965,8 @@ static void test_query_svc(void)
/* Only info level is correct. It looks like the buffer/size is checked second */
SetLastError
(
0xdeadbeef
);
ret
=
pQueryServiceStatusEx
(
NULL
,
0
,
NULL
,
0
,
&
needed
);
/* NT4
and Wine check
the handle first */
ret
=
pQueryServiceStatusEx
(
NULL
,
SC_STATUS_PROCESS_INFO
,
NULL
,
0
,
&
needed
);
/* NT4
checks
the handle first */
if
(
GetLastError
()
!=
ERROR_INVALID_HANDLE
)
{
ok
(
!
ret
,
"Expected failure
\n
"
);
...
...
@@ -981,7 +980,7 @@ static void test_query_svc(void)
statusproc
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
SERVICE_STATUS_PROCESS
));
bufsize
=
needed
;
SetLastError
(
0xdeadbeef
);
ret
=
pQueryServiceStatusEx
(
NULL
,
0
,
(
BYTE
*
)
statusproc
,
bufsize
,
&
needed
);
ret
=
pQueryServiceStatusEx
(
NULL
,
SC_STATUS_PROCESS_INFO
,
(
BYTE
*
)
statusproc
,
bufsize
,
&
needed
);
ok
(
!
ret
,
"Expected failure
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"Expected ERROR_INVALID_HANDLE, got %d
\n
"
,
GetLastError
());
...
...
@@ -989,25 +988,22 @@ static void test_query_svc(void)
/* Correct handle and info level */
SetLastError
(
0xdeadbeef
);
ret
=
pQueryServiceStatusEx
(
svc_handle
,
0
,
NULL
,
0
,
&
needed
);
ret
=
pQueryServiceStatusEx
(
svc_handle
,
SC_STATUS_PROCESS_INFO
,
NULL
,
0
,
&
needed
);
/* NT4 doesn't return the needed size */
if
(
GetLastError
()
!=
ERROR_INVALID_PARAMETER
)
{
ok
(
!
ret
,
"Expected failure
\n
"
);
todo_wine
{
ok
(
needed
==
sizeof
(
SERVICE_STATUS_PROCESS
),
"Needed buffersize is wrong : %d
\n
"
,
needed
);
ok
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
,
"Expected ERROR_INSUFFICIENT_BUFFER, got %d
\n
"
,
GetLastError
());
}
}
/* All parameters are OK but we don't have enough rights */
statusproc
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
SERVICE_STATUS_PROCESS
));
bufsize
=
sizeof
(
SERVICE_STATUS_PROCESS
);
SetLastError
(
0xdeadbeef
);
ret
=
pQueryServiceStatusEx
(
svc_handle
,
0
,
(
BYTE
*
)
statusproc
,
bufsize
,
&
needed
);
ret
=
pQueryServiceStatusEx
(
svc_handle
,
SC_STATUS_PROCESS_INFO
,
(
BYTE
*
)
statusproc
,
bufsize
,
&
needed
);
ok
(
!
ret
,
"Expected failure
\n
"
);
ok
(
GetLastError
()
==
ERROR_ACCESS_DENIED
,
"Expected ERROR_ACCESS_DENIED, got %d
\n
"
,
GetLastError
());
...
...
@@ -1021,7 +1017,7 @@ static void test_query_svc(void)
statusproc
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
SERVICE_STATUS_PROCESS
));
bufsize
=
sizeof
(
SERVICE_STATUS_PROCESS
);
SetLastError
(
0xdeadbeef
);
ret
=
pQueryServiceStatusEx
(
svc_handle
,
0
,
(
BYTE
*
)
statusproc
,
bufsize
,
&
needed
);
ret
=
pQueryServiceStatusEx
(
svc_handle
,
SC_STATUS_PROCESS_INFO
,
(
BYTE
*
)
statusproc
,
bufsize
,
&
needed
);
ok
(
ret
,
"Expected success, got error %u
\n
"
,
GetLastError
());
if
(
statusproc
->
dwCurrentState
==
SERVICE_RUNNING
)
ok
(
statusproc
->
dwProcessId
!=
0
,
...
...
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