Loop around calling RegQueryValue until we have a big enough string
for both the name and the value.
This commit is contained in:
parent
5c4eee1385
commit
77da201e8f
|
@ -773,7 +773,7 @@ UINT WINAPI MSI_EnumComponentQualifiers( LPCWSTR szComponent, DWORD iIndex,
|
||||||
awstring *lpQualBuf, DWORD* pcchQual,
|
awstring *lpQualBuf, DWORD* pcchQual,
|
||||||
awstring *lpAppBuf, DWORD* pcchAppBuf )
|
awstring *lpAppBuf, DWORD* pcchAppBuf )
|
||||||
{
|
{
|
||||||
DWORD name_sz, val_sz, type, ofs;
|
DWORD name_sz, val_sz, name_max, val_max, type, ofs;
|
||||||
LPWSTR name = NULL, val = NULL;
|
LPWSTR name = NULL, val = NULL;
|
||||||
UINT r, r2;
|
UINT r, r2;
|
||||||
HKEY key;
|
HKEY key;
|
||||||
|
@ -789,40 +789,57 @@ UINT WINAPI MSI_EnumComponentQualifiers( LPCWSTR szComponent, DWORD iIndex,
|
||||||
return ERROR_UNKNOWN_COMPONENT;
|
return ERROR_UNKNOWN_COMPONENT;
|
||||||
|
|
||||||
/* figure out how big the name is we want to return */
|
/* figure out how big the name is we want to return */
|
||||||
name_sz = 0;
|
name_max = 0x10;
|
||||||
if (pcchQual)
|
r = ERROR_OUTOFMEMORY;
|
||||||
{
|
name = msi_alloc( name_max * sizeof(WCHAR) );
|
||||||
r = ERROR_OUTOFMEMORY;
|
if (!name)
|
||||||
name_sz = *pcchQual * 4;
|
|
||||||
name = msi_alloc( name_sz * sizeof(WCHAR) );
|
|
||||||
if (!name)
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* figure out how big the value is */
|
|
||||||
type = 0;
|
|
||||||
val_sz = 0;
|
|
||||||
r = RegEnumValueW( key, iIndex, NULL, NULL,
|
|
||||||
NULL, &type, NULL, &val_sz );
|
|
||||||
if (r != ERROR_SUCCESS)
|
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
if (type != REG_MULTI_SZ)
|
val_max = 0x10;
|
||||||
{
|
r = ERROR_OUTOFMEMORY;
|
||||||
ERR("component data has wrong type (%ld)\n", type);
|
val = msi_alloc( val_max );
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* the value size is in bytes */
|
|
||||||
val_sz += sizeof(WCHAR);
|
|
||||||
val = msi_alloc( val_sz );
|
|
||||||
if (!val)
|
if (!val)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
r = RegEnumValueW( key, iIndex, name, &name_sz,
|
/* loop until we allocate enough memory */
|
||||||
NULL, &type, (LPBYTE)val, &val_sz );
|
while (1)
|
||||||
if (r != ERROR_SUCCESS)
|
{
|
||||||
|
name_sz = name_max;
|
||||||
|
val_sz = val_max;
|
||||||
|
r = RegEnumValueW( key, iIndex, name, &name_sz,
|
||||||
|
NULL, &type, (LPBYTE)val, &val_sz );
|
||||||
|
if (r == ERROR_SUCCESS)
|
||||||
|
break;
|
||||||
|
if (r != ERROR_MORE_DATA)
|
||||||
|
goto end;
|
||||||
|
|
||||||
|
if (type != REG_MULTI_SZ)
|
||||||
|
{
|
||||||
|
ERR("component data has wrong type (%ld)\n", type);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
r = ERROR_OUTOFMEMORY;
|
||||||
|
if ((name_sz+1) >= name_max)
|
||||||
|
{
|
||||||
|
name_max *= 2;
|
||||||
|
msi_free( name );
|
||||||
|
name = msi_alloc( name_max * sizeof (WCHAR) );
|
||||||
|
if (!name)
|
||||||
|
goto end;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (val_sz > val_max)
|
||||||
|
{
|
||||||
|
val_max = val_sz + sizeof (WCHAR);
|
||||||
|
val = msi_alloc( val_max * sizeof (WCHAR) );
|
||||||
|
if (!val)
|
||||||
|
goto end;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ERR("should be enough data, but isn't %ld %ld\n", name_sz, val_sz );
|
||||||
goto end;
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
ofs = 0;
|
ofs = 0;
|
||||||
r = MsiDecomposeDescriptorW( val, NULL, NULL, NULL, &ofs );
|
r = MsiDecomposeDescriptorW( val, NULL, NULL, NULL, &ofs );
|
||||||
|
|
Loading…
Reference in New Issue