From 18922ff0a490685fda05a935fcec14372934bf09 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Fri, 6 Feb 2009 08:51:20 +0000 Subject: [PATCH] fix some QueryServiceConfig2A winetests svn path=/trunk/; revision=39433 --- reactos/base/system/services/rpcserver.c | 50 ++++++++++++------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/reactos/base/system/services/rpcserver.c b/reactos/base/system/services/rpcserver.c index 5419438b8c1..5ffd2d91a41 100644 --- a/reactos/base/system/services/rpcserver.c +++ b/reactos/base/system/services/rpcserver.c @@ -4209,7 +4209,6 @@ DWORD RQueryServiceConfig2A( PSERVICE_HANDLE hSvc; PSERVICE lpService = NULL; HKEY hServiceKey = NULL; - DWORD dwRequiredSize; LPWSTR lpDescriptionW = NULL; LPSTR lpDescription = NULL; @@ -4255,39 +4254,42 @@ DWORD RQueryServiceConfig2A( LPSERVICE_DESCRIPTIONA lpServiceDescription = (LPSERVICE_DESCRIPTIONA)lpBuffer; LPSTR lpStr; + *pcbBytesNeeded = sizeof(SERVICE_DESCRIPTIONA); + dwError = ScmReadString(hServiceKey, L"Description", &lpDescriptionW); - if (dwError != ERROR_SUCCESS) + if (dwError == ERROR_SUCCESS) { - if (cbBufSize < sizeof(SERVICE_DESCRIPTIONA)) + *pcbBytesNeeded += ((wcslen(lpDescriptionW) + 1)); + } + + if (cbBufSize >= *pcbBytesNeeded) + { + + if (dwError == ERROR_SUCCESS) { - *pcbBytesNeeded = sizeof(SERVICE_DESCRIPTIONA); - dwError = ERROR_INSUFFICIENT_BUFFER; + lpStr = (LPSTR)(lpServiceDescription + 1); + + WideCharToMultiByte(CP_ACP, + 0, + lpDescriptionW, + -1, + lpStr, + wcslen(lpDescriptionW), + NULL, + NULL); + lpServiceDescription->lpDescription = (LPSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpServiceDescription); + } + else + { + lpServiceDescription->lpDescription = NULL; } - goto done; } - - dwRequiredSize = sizeof(SERVICE_DESCRIPTIONA) + ((wcslen(lpDescriptionW) + 1)); - - if (cbBufSize < dwRequiredSize) + else { - *pcbBytesNeeded = dwRequiredSize; dwError = ERROR_INSUFFICIENT_BUFFER; - goto done; } - - lpStr = (LPSTR)(lpServiceDescription + 1); - - WideCharToMultiByte(CP_ACP, - 0, - lpDescriptionW, - -1, - lpStr, - wcslen(lpDescriptionW), - NULL, - NULL); - lpServiceDescription->lpDescription = (LPSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpServiceDescription); } else if (dwInfoLevel & SERVICE_CONFIG_FAILURE_ACTIONS) {