James Hawkins : msi: Fix handling of the NULL separator when writing registry values.

Alexandre Julliard julliard at winehq.org
Tue Feb 5 06:34:48 CST 2008


Module: wine
Branch: master
Commit: 2f658cb337871cde2d05849fbc3f5408f4ce799e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=2f658cb337871cde2d05849fbc3f5408f4ce799e

Author: James Hawkins <truiken at gmail.com>
Date:   Mon Feb  4 19:06:53 2008 -0600

msi: Fix handling of the NULL separator when writing registry values.

---

 dlls/msi/action.c        |   24 ++++++++++++++++++
 dlls/msi/tests/install.c |   61 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 85 insertions(+), 0 deletions(-)

diff --git a/dlls/msi/action.c b/dlls/msi/action.c
index 5b940c6..2efcbbb 100644
--- a/dlls/msi/action.c
+++ b/dlls/msi/action.c
@@ -2240,6 +2240,7 @@ static LPSTR parse_value(MSIPACKAGE *package, LPCWSTR value, DWORD *type,
                          DWORD *size)
 {
     LPSTR data = NULL;
+
     if (value[0]=='#' && value[1]!='#' && value[1]!='%')
     {
         if (value[1]=='x')
@@ -2321,6 +2322,7 @@ static LPSTR parse_value(MSIPACKAGE *package, LPCWSTR value, DWORD *type,
     {
         static const WCHAR szMulti[] = {'[','~',']',0};
         LPCWSTR ptr;
+        LPWSTR newdata;
         *type=REG_SZ;
 
         if (value[0]=='#')
@@ -2339,7 +2341,29 @@ static LPSTR parse_value(MSIPACKAGE *package, LPCWSTR value, DWORD *type,
         if (strstrW(value,szMulti))
             *type = REG_MULTI_SZ;
 
+        /* remove initial delimiter */
+        if (!strncmpW(value, szMulti, 3))
+            ptr = value + 3;
+
         *size = deformat_string(package, ptr,(LPWSTR*)&data);
+
+        /* add double NULL terminator */
+        if (*type == REG_MULTI_SZ)
+        {
+            *size += sizeof(WCHAR);
+            newdata = msi_alloc(*size);
+            if (!newdata)
+            {
+                msi_free(data);
+                return NULL;
+            }
+
+            memcpy(newdata, data, *size - 1);
+            newdata[*size] = '\0';
+
+            msi_free(data);
+            data = (LPSTR)newdata;
+        }
     }
     return data;
 }
diff --git a/dlls/msi/tests/install.c b/dlls/msi/tests/install.c
index d394908..b5892c0 100644
--- a/dlls/msi/tests/install.c
+++ b/dlls/msi/tests/install.c
@@ -576,6 +576,16 @@ static const CHAR df_duplicate_file_dat[] = "FileKey\tComponent_\tFile_\tDestNam
                                             "maximus\tmaximus\tmaximus\taugustus\t\n"
                                             "caesar\tmaximus\tmaximus\t\tNONEXISTENT\n";
 
+static const CHAR wrv_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
+                                        "s72\tS38\ts72\ti2\tS255\tS72\n"
+                                        "Component\tComponent\n"
+                                        "augustus\t\tMSITESTDIR\t0\t\taugustus\n";
+
+static const CHAR wrv_registry_dat[] = "Registry\tRoot\tKey\tName\tValue\tComponent_\n"
+                                       "s72\ti2\tl255\tL255\tL0\ts72\n"
+                                       "Registry\tRegistry\n"
+                                       "regdata\t2\tSOFTWARE\\Wine\\msitest\tValue\t[~]one[~]two[~]three\taugustus";
+
 typedef struct _msi_table
 {
     const CHAR *filename;
@@ -864,6 +874,19 @@ static const msi_table df_tables[] =
     ADD_TABLE(df_duplicate_file),
 };
 
+static const msi_table wrv_tables[] =
+{
+    ADD_TABLE(wrv_component),
+    ADD_TABLE(directory),
+    ADD_TABLE(rof_feature),
+    ADD_TABLE(ci2_feature_comp),
+    ADD_TABLE(ci2_file),
+    ADD_TABLE(install_exec_seq),
+    ADD_TABLE(rof_media),
+    ADD_TABLE(property),
+    ADD_TABLE(wrv_registry),
+};
+
 /* cabinet definitions */
 
 /* make the max size large so there is only one cab file */
@@ -3625,6 +3648,43 @@ static void test_duplicatefiles(void)
     DeleteFile(msifile);
 }
 
+static void test_writeregistryvalues(void)
+{
+    UINT r;
+    LONG res;
+    HKEY hkey;
+    DWORD type, size;
+    CHAR path[MAX_PATH];
+
+    CreateDirectoryA("msitest", NULL);
+    create_file("msitest\\augustus", 500);
+
+    create_database(msifile, wrv_tables, sizeof(wrv_tables) / sizeof(msi_table));
+
+    MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
+
+    r = MsiInstallProductA(msifile, NULL);
+    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
+    ok(delete_pf("msitest\\augustus", TRUE), "File installed\n");
+    ok(delete_pf("msitest", FALSE), "File installed\n");
+
+    res = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest", &hkey);
+    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+    size = MAX_PATH;
+    type = REG_MULTI_SZ;
+    memset(path, 'a', MAX_PATH);
+    res = RegQueryValueExA(hkey, "Value", NULL, &type, (LPBYTE)path, &size);
+    ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+    ok(!memcmp(path, "one\0two\0three\0\0", size), "Wrong multi-sz data\n");
+    ok(size == 15, "Expected 15, got %d\n", size);
+    ok(type == REG_MULTI_SZ, "Expected REG_MULTI_SZ, got %d\n", type);
+
+    DeleteFile(msifile);
+    DeleteFile("msitest\\augustus");
+    RemoveDirectory("msitest");
+}
+
 START_TEST(install)
 {
     DWORD len;
@@ -3667,6 +3727,7 @@ START_TEST(install)
     test_movefiles();
     test_missingcab();
     test_duplicatefiles();
+    test_writeregistryvalues();
 
     SetCurrentDirectoryA(prev_path);
 }




More information about the wine-cvs mailing list