Rob Shearman : msi: Passing NULL for szBuffer and NULL for pcchValueBuf into MsiGetProductInfo{A , W} shouldn't crash.
Alexandre Julliard
julliard at winehq.org
Wed Mar 12 17:24:00 CDT 2008
Module: wine
Branch: master
Commit: 58130dde08396f2b93481e9166f6ecae4a4446e2
URL: http://source.winehq.org/git/wine.git/?a=commit;h=58130dde08396f2b93481e9166f6ecae4a4446e2
Author: Rob Shearman <rob at codeweavers.com>
Date: Wed Mar 12 17:40:51 2008 +0000
msi: Passing NULL for szBuffer and NULL for pcchValueBuf into MsiGetProductInfo{A, W} shouldn't crash.
Add a test for this.
---
dlls/msi/msi.c | 27 ++++++++++++++++-----------
dlls/msi/tests/msi.c | 4 ++++
2 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/dlls/msi/msi.c b/dlls/msi/msi.c
index 85446e8..32a4173 100644
--- a/dlls/msi/msi.c
+++ b/dlls/msi/msi.c
@@ -722,20 +722,25 @@ static UINT WINAPI MSI_GetProductInfo(LPCWSTR szProduct, LPCWSTR szAttribute,
goto done;
}
- save = *pcchValueBuf;
+ if (pcchValueBuf)
+ {
+ 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 (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;
+ 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);
diff --git a/dlls/msi/tests/msi.c b/dlls/msi/tests/msi.c
index f82a9a9..5da8673 100644
--- a/dlls/msi/tests/msi.c
+++ b/dlls/msi/tests/msi.c
@@ -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);
More information about the wine-cvs
mailing list