Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/msi/install.c | 4 ++++ dlls/msi/tests/package.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+)
diff --git a/dlls/msi/install.c b/dlls/msi/install.c index 65840e2..814addc 100644 --- a/dlls/msi/install.c +++ b/dlls/msi/install.c @@ -180,7 +180,11 @@ UINT msi_strcpy_to_awstring( const WCHAR *str, int len, awstring *awbuf, DWORD * if (len < 0) len = strlenW( str );
if (awbuf->unicode && awbuf->str.w) + { memcpy( awbuf->str.w, str, min(len + 1, *sz) * sizeof(WCHAR) ); + if (*sz && len >= *sz) + awbuf->str.w[*sz - 1] = 0; + } else { int lenA = WideCharToMultiByte( CP_ACP, 0, str, len + 1, NULL, 0, NULL, NULL ); diff --git a/dlls/msi/tests/package.c b/dlls/msi/tests/package.c index 6414891..b85a3a8 100644 --- a/dlls/msi/tests/package.c +++ b/dlls/msi/tests/package.c @@ -2150,10 +2150,14 @@ static void check_prop(MSIHANDLE hpkg, const char *prop, const char *expect)
static void test_props(void) { + static const WCHAR booW[] = {'b','o','o',0}; + static const WCHAR xyzW[] = {'x','y','z',0}; + static const WCHAR xyW[] = {'x','y',0}; MSIHANDLE hpkg, hdb; UINT r; DWORD sz; char buffer[0x100]; + WCHAR bufferW[10];
hdb = create_package_db();
@@ -2280,6 +2284,39 @@ static void test_props(void) ok(!strcmp(buffer,"xyz"), "got "%s"\n", buffer); ok(sz == 3, "got size %u\n", sz);
+ sz = 0; + r = MsiGetPropertyW(hpkg, booW, NULL, &sz); + ok(!r, "got %u\n", r); + ok(sz == 3, "got size %u\n", sz); + + sz = 0; + lstrcpyW(bufferW, booW); + r = MsiGetPropertyW(hpkg, booW, bufferW, &sz); + ok(r == ERROR_MORE_DATA, "got %u\n", r); + ok(!lstrcmpW(bufferW, booW), "got %s\n", wine_dbgstr_w(bufferW)); + ok(sz == 3, "got size %u\n", sz); + + sz = 1; + lstrcpyW(bufferW, booW); + r = MsiGetPropertyW(hpkg, booW, bufferW, &sz ); + ok(r == ERROR_MORE_DATA, "got %u\n", r); + ok(!bufferW[0], "got %s\n", wine_dbgstr_w(bufferW)); + ok(sz == 3, "got size %u\n", sz); + + sz = 3; + lstrcpyW(bufferW, booW); + r = MsiGetPropertyW(hpkg, booW, bufferW, &sz ); + ok(r == ERROR_MORE_DATA, "got %u\n", r); + ok(!lstrcmpW(bufferW, xyW), "got %s\n", wine_dbgstr_w(bufferW)); + ok(sz == 3, "got size %u\n", sz); + + sz = 4; + lstrcpyW(bufferW, booW); + r = MsiGetPropertyW(hpkg, booW, bufferW, &sz ); + ok(!r, "got %u\n", r); + ok(!lstrcmpW(bufferW, xyzW), "got %s\n", wine_dbgstr_w(bufferW)); + ok(sz == 3, "got size %u\n", sz); + /* properties are case-sensitive */ check_prop(hpkg, "BOO", "");