https://git.reactos.org/?p=reactos.git;a=commitdiff;h=616d504d32474b244e77a…
commit 616d504d32474b244e77ab63cdedb110216bde51
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Sun Mar 13 01:21:42 2022 +0100
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Sun Mar 20 19:28:17 2022 +0100
[WINESYNC] msi: Perform partial copies in MsiViewGetError().
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 6a3dbf11923b96c93f1869c9b9ed34d68bdb2576 by Zebediah Figura
<z.figura12(a)gmail.com>
---
dll/win32/msi/msiquery.c | 26 ++++++--------------------
modules/rostests/winetests/msi/db.c | 4 ++--
2 files changed, 8 insertions(+), 22 deletions(-)
diff --git a/dll/win32/msi/msiquery.c b/dll/win32/msi/msiquery.c
index 9f4c5975306..524cb7898b4 100644
--- a/dll/win32/msi/msiquery.c
+++ b/dll/win32/msi/msiquery.c
@@ -772,7 +772,6 @@ MSIDBERROR WINAPI MsiViewGetErrorW( MSIHANDLE handle, LPWSTR buffer,
LPDWORD buf
MSIQUERY *query;
const WCHAR *column;
MSIDBERROR r;
- DWORD len;
TRACE("%u %p %p\n", handle, buffer, buflen);
@@ -786,15 +785,9 @@ MSIDBERROR WINAPI MsiViewGetErrorW( MSIHANDLE handle, LPWSTR buffer,
LPDWORD buf
if ((r = query->view->error)) column = query->view->error_column;
else column = szEmpty;
- len = strlenW( column );
- if (buffer)
- {
- if (*buflen > len)
- strcpyW( buffer, column );
- else
- r = MSIDBERROR_MOREDATA;
- }
- *buflen = len;
+ if (msi_strncpyW(column, -1, buffer, buflen) == ERROR_MORE_DATA)
+ r = MSIDBERROR_MOREDATA;
+
msiobj_release( &query->hdr );
return r;
}
@@ -804,7 +797,6 @@ MSIDBERROR WINAPI MsiViewGetErrorA( MSIHANDLE handle, LPSTR buffer,
LPDWORD bufl
MSIQUERY *query;
const WCHAR *column;
MSIDBERROR r;
- DWORD len;
TRACE("%u %p %p\n", handle, buffer, buflen);
@@ -818,15 +810,9 @@ MSIDBERROR WINAPI MsiViewGetErrorA( MSIHANDLE handle, LPSTR buffer,
LPDWORD bufl
if ((r = query->view->error)) column = query->view->error_column;
else column = szEmpty;
- len = WideCharToMultiByte( CP_ACP, 0, column, -1, NULL, 0, NULL, NULL );
- if (buffer)
- {
- if (*buflen >= len)
- WideCharToMultiByte( CP_ACP, 0, column, -1, buffer, *buflen, NULL, NULL );
- else
- r = MSIDBERROR_MOREDATA;
- }
- *buflen = len - 1;
+ if (msi_strncpyWtoA(column, -1, buffer, buflen, FALSE) == ERROR_MORE_DATA)
+ r = MSIDBERROR_MOREDATA;
+
msiobj_release( &query->hdr );
return r;
}
diff --git a/modules/rostests/winetests/msi/db.c b/modules/rostests/winetests/msi/db.c
index 16b20e530bc..181301e1fe9 100644
--- a/modules/rostests/winetests/msi/db.c
+++ b/modules/rostests/winetests/msi/db.c
@@ -9163,14 +9163,14 @@ static void test_view_get_error(void)
strcpy(buffer, "x");
err = MsiViewGetErrorA(view, buffer, &sz);
ok(err == MSIDBERROR_MOREDATA, "got %d\n", err);
- todo_wine ok(!buffer[0], "got \"%s\"\n", buffer);
+ ok(!buffer[0], "got \"%s\"\n", buffer);
ok(sz == 1, "got size %u\n", sz);
sz = 1;
strcpy(buffer, "x");
err = MsiViewGetErrorA(view, buffer, &sz);
todo_wine ok(err == MSIDBERROR_NOERROR, "got %d\n", err);
- todo_wine ok(!buffer[0], "got \"%s\"\n", buffer);
+ ok(!buffer[0], "got \"%s\"\n", buffer);
todo_wine ok(sz == 0, "got size %u\n", sz);
r = MsiViewModify(view, MSIMODIFY_VALIDATE_NEW, rec);