msi: Make sure we don't access pcchValueBuf when szBuffer is NULL, as pcchValueBuf is not required to be initialized in this case.
This commit is contained in:
parent
f823f2181e
commit
f4829063bc
|
@ -901,7 +901,7 @@ static UINT MSI_GetProductInfo(LPCWSTR szProduct, LPCWSTR szAttribute,
|
||||||
WCHAR packagecode[GUID_SIZE];
|
WCHAR packagecode[GUID_SIZE];
|
||||||
BOOL badconfig = FALSE;
|
BOOL badconfig = FALSE;
|
||||||
LONG res;
|
LONG res;
|
||||||
DWORD save, type = REG_NONE;
|
DWORD type = REG_NONE;
|
||||||
|
|
||||||
static WCHAR empty[] = {0};
|
static WCHAR empty[] = {0};
|
||||||
static const WCHAR sourcelist[] = {
|
static const WCHAR sourcelist[] = {
|
||||||
|
@ -1036,22 +1036,26 @@ static UINT MSI_GetProductInfo(LPCWSTR szProduct, LPCWSTR szAttribute,
|
||||||
|
|
||||||
if (pcchValueBuf)
|
if (pcchValueBuf)
|
||||||
{
|
{
|
||||||
save = *pcchValueBuf;
|
/* If szBuffer (szValue->str) is NULL, there's no need to copy the value
|
||||||
|
* out. Also, *pcchValueBuf may be uninitialized in this case, so we
|
||||||
if (strlenW(val) < *pcchValueBuf)
|
* can't rely on its value.
|
||||||
r = msi_strcpy_to_awstring(val, szValue, pcchValueBuf);
|
*/
|
||||||
else if (szValue->str.a || szValue->str.w)
|
if (szValue->str.a || szValue->str.w)
|
||||||
|
{
|
||||||
|
DWORD size = *pcchValueBuf;
|
||||||
|
if (strlenW(val) < size)
|
||||||
|
r = msi_strcpy_to_awstring(val, szValue, &size);
|
||||||
|
else
|
||||||
|
{
|
||||||
r = ERROR_MORE_DATA;
|
r = ERROR_MORE_DATA;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!badconfig)
|
if (!badconfig)
|
||||||
*pcchValueBuf = lstrlenW(val);
|
*pcchValueBuf = lstrlenW(val);
|
||||||
else if (r == ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
*pcchValueBuf = save;
|
|
||||||
r = ERROR_BAD_CONFIGURATION;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (badconfig)
|
if (badconfig)
|
||||||
r = ERROR_BAD_CONFIGURATION;
|
r = ERROR_BAD_CONFIGURATION;
|
||||||
|
|
||||||
if (val != empty)
|
if (val != empty)
|
||||||
|
|
|
@ -2779,7 +2779,7 @@ static void test_MsiGetProductInfo(void)
|
||||||
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
|
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
|
||||||
ok(sz == 4, "Expected 4, got %d\n", sz);
|
ok(sz == 4, "Expected 4, got %d\n", sz);
|
||||||
|
|
||||||
/* lpValueBuf is NULL, pcchValueBuf is too small */
|
/* lpValueBuf is non-NULL, pcchValueBuf is too small */
|
||||||
sz = 2;
|
sz = 2;
|
||||||
lstrcpyA(buf, "apple");
|
lstrcpyA(buf, "apple");
|
||||||
r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
|
r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
|
||||||
|
@ -2787,7 +2787,7 @@ static void test_MsiGetProductInfo(void)
|
||||||
ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
|
ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
|
||||||
ok(sz == 4, "Expected 4, got %d\n", sz);
|
ok(sz == 4, "Expected 4, got %d\n", sz);
|
||||||
|
|
||||||
/* lpValueBuf is NULL, pcchValueBuf is exactly 4 */
|
/* lpValueBuf is non-NULL, pcchValueBuf is exactly 4 */
|
||||||
sz = 4;
|
sz = 4;
|
||||||
lstrcpyA(buf, "apple");
|
lstrcpyA(buf, "apple");
|
||||||
r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
|
r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
|
||||||
|
|
Loading…
Reference in New Issue