only allocate a buffer in StartServiceA when dwNumServiceArgs > 0

adjust the image path in services/rpcserver

svn path=/trunk/; revision=31761
This commit is contained in:
Christoph von Wittich 2008-01-13 14:22:55 +00:00
parent 16f2303c0b
commit ea6661ca60
2 changed files with 35 additions and 25 deletions

View file

@ -1058,18 +1058,25 @@ ScmrCreateServiceW(handle_t BindingHandle,
if (dwServiceType & SERVICE_DRIVER)
{
/* FIXME: Adjust the image path */
lpImagePath = (WCHAR*) HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
(wcslen(lpBinaryPathName) + 1) * sizeof(WCHAR));
(wcslen(lpBinaryPathName) + 5) * sizeof(WCHAR));
if (lpImagePath == NULL)
{
dwError = ERROR_NOT_ENOUGH_MEMORY;
goto done;
}
if (lpBinaryPathName[1] == L':')
{
wcscpy(lpImagePath, L"\\??\\");
wcscat(lpImagePath, lpBinaryPathName);
}
else
{
wcscpy(lpImagePath, lpBinaryPathName);
}
}
/* Allocate a new service entry */
dwError = ScmCreateNewServiceRecord(lpServiceName,

View file

@ -1998,13 +1998,14 @@ StartServiceA(SC_HANDLE hService,
DWORD dwNumServiceArgs,
LPCSTR *lpServiceArgVectors)
{
LPSTR lpBuffer;
LPSTR lpBuffer = NULL;
LPSTR lpStr;
DWORD dwError;
DWORD dwBufSize;
DWORD dwBufSize = 0;
DWORD i;
dwBufSize = 0;
if (dwNumServiceArgs > 0)
{
for (i = 0; i < dwNumServiceArgs; i++)
{
dwBufSize += (strlen(lpServiceArgVectors[i]) + 1);
@ -2026,6 +2027,7 @@ StartServiceA(SC_HANDLE hService,
lpStr += (strlen(lpServiceArgVectors[i]) + 1);
}
*lpStr = 0;
}
dwError = ScmrStartServiceA(BindingHandle,
(unsigned int)hService,
@ -2033,6 +2035,7 @@ StartServiceA(SC_HANDLE hService,
(unsigned char *)lpBuffer,
dwBufSize);
if (lpBuffer != NULL)
HeapFree(GetProcessHeap(), 0, lpBuffer);
if (dwError != ERROR_SUCCESS)