advapi32: Fixed NULL ptr deref in QueryServiceConfig2A (Coverity).

This commit is contained in:
Marcus Meissner 2009-01-31 11:40:02 +01:00 committed by Alexandre Julliard
parent 0aa5a83688
commit 45a1269013
1 changed files with 5 additions and 3 deletions

View File

@ -1365,9 +1365,10 @@ BOOL WINAPI QueryServiceConfig2A(SC_HANDLE hService, DWORD dwLevel, LPBYTE buffe
switch(dwLevel) { switch(dwLevel) {
case SERVICE_CONFIG_DESCRIPTION: case SERVICE_CONFIG_DESCRIPTION:
{ LPSERVICE_DESCRIPTIONA configA = (LPSERVICE_DESCRIPTIONA) buffer; if (buffer && bufferW) {
LPSERVICE_DESCRIPTIONA configA = (LPSERVICE_DESCRIPTIONA) buffer;
LPSERVICE_DESCRIPTIONW configW = (LPSERVICE_DESCRIPTIONW) bufferW; LPSERVICE_DESCRIPTIONW configW = (LPSERVICE_DESCRIPTIONW) bufferW;
if (configW->lpDescription) { if (configW->lpDescription && (size > sizeof(SERVICE_DESCRIPTIONA))) {
DWORD sz; DWORD sz;
configA->lpDescription = (LPSTR)(configA + 1); configA->lpDescription = (LPSTR)(configA + 1);
sz = WideCharToMultiByte( CP_ACP, 0, configW->lpDescription, -1, sz = WideCharToMultiByte( CP_ACP, 0, configW->lpDescription, -1,
@ -1380,10 +1381,11 @@ BOOL WINAPI QueryServiceConfig2A(SC_HANDLE hService, DWORD dwLevel, LPBYTE buffe
} }
else configA->lpDescription = NULL; else configA->lpDescription = NULL;
} }
break; break;
default: default:
FIXME("conversation W->A not implemented for level %d\n", dwLevel); FIXME("conversation W->A not implemented for level %d\n", dwLevel);
ret = FALSE; ret = FALSE;
break;
} }
cleanup: cleanup: