Return an empty string for service dependencies when there are no
dependencies, rather than a NULL pointer, which causes some apps to SEGV.
This commit is contained in:
parent
64db533173
commit
4021f530d7
|
@ -1792,6 +1792,8 @@ QueryServiceConfigW( SC_HANDLE hService,
|
||||||
r = RegQueryValueExW( hKey, szDependencies, 0, &type, NULL, &sz );
|
r = RegQueryValueExW( hKey, szDependencies, 0, &type, NULL, &sz );
|
||||||
if( ( r == ERROR_SUCCESS ) && ( type == REG_MULTI_SZ ) )
|
if( ( r == ERROR_SUCCESS ) && ( type == REG_MULTI_SZ ) )
|
||||||
total += sz;
|
total += sz;
|
||||||
|
else
|
||||||
|
total += sizeof(WCHAR);
|
||||||
|
|
||||||
sz = 0;
|
sz = 0;
|
||||||
r = RegQueryValueExW( hKey, szStart, 0, &type, NULL, &sz );
|
r = RegQueryValueExW( hKey, szStart, 0, &type, NULL, &sz );
|
||||||
|
@ -1862,12 +1864,18 @@ QueryServiceConfigW( SC_HANDLE hService,
|
||||||
|
|
||||||
sz = n;
|
sz = n;
|
||||||
r = RegQueryValueExW( hKey, szDependencies, 0, &type, p, &sz );
|
r = RegQueryValueExW( hKey, szDependencies, 0, &type, p, &sz );
|
||||||
|
lpServiceConfig->lpDependencies = (LPWSTR) p;
|
||||||
if( ( r == ERROR_SUCCESS ) || ( type == REG_SZ ) )
|
if( ( r == ERROR_SUCCESS ) || ( type == REG_SZ ) )
|
||||||
{
|
{
|
||||||
lpServiceConfig->lpDependencies = (LPWSTR) p;
|
|
||||||
p += sz;
|
p += sz;
|
||||||
n -= sz;
|
n -= sz;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*(WCHAR *) p = 0;
|
||||||
|
p += sizeof(WCHAR);
|
||||||
|
n -= sizeof(WCHAR);
|
||||||
|
}
|
||||||
|
|
||||||
if( n < 0 )
|
if( n < 0 )
|
||||||
ERR("Buffer overflow!\n");
|
ERR("Buffer overflow!\n");
|
||||||
|
|
Loading…
Reference in New Issue