msi: Passing NULL for szBuffer and NULL for pcchValueBuf into MsiGetProductInfo{A, W} shouldn't crash.

Add a test for this.
This commit is contained in:
Rob Shearman 2008-03-12 17:40:51 +00:00 committed by Alexandre Julliard
parent dd31a1eac4
commit 58130dde08
2 changed files with 21 additions and 12 deletions

View File

@ -722,20 +722,25 @@ static UINT WINAPI MSI_GetProductInfo(LPCWSTR szProduct, LPCWSTR szAttribute,
goto done;
}
save = *pcchValueBuf;
if (lstrlenW(val) < *pcchValueBuf)
r = msi_strcpy_to_awstring(val, szValue, pcchValueBuf);
else if (szValue->str.a || szValue->str.w)
r = ERROR_MORE_DATA;
if (!badconfig)
*pcchValueBuf = lstrlenW(val);
else if (r == ERROR_SUCCESS)
if (pcchValueBuf)
{
*pcchValueBuf = save;
r = ERROR_BAD_CONFIGURATION;
save = *pcchValueBuf;
if (lstrlenW(val) < *pcchValueBuf)
r = msi_strcpy_to_awstring(val, szValue, pcchValueBuf);
else if (szValue->str.a || szValue->str.w)
r = ERROR_MORE_DATA;
if (!badconfig)
*pcchValueBuf = lstrlenW(val);
else if (r == ERROR_SUCCESS)
{
*pcchValueBuf = save;
r = ERROR_BAD_CONFIGURATION;
}
}
else if (badconfig)
r = ERROR_BAD_CONFIGURATION;
if (val != empty)
msi_free(val);

View File

@ -2233,6 +2233,10 @@ static void test_MsiGetProductInfo(void)
ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
ok(sz == 4, "Expected 4, got %d\n", sz);
/* pcchBuf is NULL */
r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, NULL, NULL);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
/* lpValueBuf is NULL */
sz = MAX_PATH;
r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, NULL, &sz);