https://git.reactos.org/?p=reactos.git;a=commitdiff;h=66669aedeae50e9956870…
commit 66669aedeae50e99568701e8ec4563ad5b8463e0
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Sat Mar 12 15:11:47 2022 +0100
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Sun Mar 20 19:27:35 2022 +0100
[WINESYNC] msi: Also null-terminate WCHAR strings.
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
wine commit id f37e61817f0393132c75b2e5d86778d1a4ceab45 by Zebediah Figura
<z.figura12(a)gmail.com>
---
dll/win32/msi/install.c | 4 ++++
modules/rostests/winetests/msi/package.c | 37 ++++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+)
diff --git a/dll/win32/msi/install.c b/dll/win32/msi/install.c
index 65840e28f47..814addc402f 100644
--- a/dll/win32/msi/install.c
+++ b/dll/win32/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/modules/rostests/winetests/msi/package.c
b/modules/rostests/winetests/msi/package.c
index 6414891059d..b85a3a810dc 100644
--- a/modules/rostests/winetests/msi/package.c
+++ b/modules/rostests/winetests/msi/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", "");