From 0b60ed8ff17dbf79eabb6ae79bc858b4c65fe360 Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Tue, 4 Aug 2009 12:19:42 +0200 Subject: [PATCH] msi: Fix parsing of integer column width specifiers. --- dlls/msi/database.c | 10 +++++-- dlls/msi/tests/install.c | 61 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 2 deletions(-) diff --git a/dlls/msi/database.c b/dlls/msi/database.c index 4c21876c49a..173657e1b70 100644 --- a/dlls/msi/database.c +++ b/dlls/msi/database.c @@ -413,10 +413,16 @@ static LPWSTR msi_build_createsql_columns(LPWSTR *columns_data, LPWSTR *types, D case 'i': lstrcpyW(extra, type_notnull); case 'I': - if (len == 2) + if (len <= 2) type = type_int; - else + else if (len == 4) type = type_long; + else + { + WARN("invalid int width %u\n", len); + msi_free(columns); + return NULL; + } break; case 'v': lstrcpyW(extra, type_notnull); diff --git a/dlls/msi/tests/install.c b/dlls/msi/tests/install.c index e6c22fb745c..0a54ea6f4ae 100644 --- a/dlls/msi/tests/install.c +++ b/dlls/msi/tests/install.c @@ -6050,6 +6050,66 @@ static void test_propcase(void) RemoveDirectory("msitest"); } +static void test_int_widths( void ) +{ + static const char int0[] = "int0\ni0\nint0\tint0\n1"; + static const char int1[] = "int1\ni1\nint1\tint1\n1"; + static const char int2[] = "int2\ni2\nint2\tint2\n1"; + static const char int3[] = "int3\ni3\nint3\tint3\n1"; + static const char int4[] = "int4\ni4\nint4\tint4\n1"; + static const char int5[] = "int5\ni5\nint5\tint5\n1"; + static const char int8[] = "int8\ni8\nint8\tint8\n1"; + + static const struct + { + const char *data; + unsigned int size; + UINT ret; + } + tests[] = + { + { int0, sizeof(int0) - 1, ERROR_SUCCESS }, + { int1, sizeof(int1) - 1, ERROR_SUCCESS }, + { int2, sizeof(int2) - 1, ERROR_SUCCESS }, + { int3, sizeof(int3) - 1, ERROR_FUNCTION_FAILED }, + { int4, sizeof(int4) - 1, ERROR_SUCCESS }, + { int5, sizeof(int5) - 1, ERROR_FUNCTION_FAILED }, + { int8, sizeof(int8) - 1, ERROR_FUNCTION_FAILED } + }; + + char tmpdir[MAX_PATH], msitable[MAX_PATH], msidb[MAX_PATH]; + MSIHANDLE db; + UINT r, i; + + GetTempPathA(MAX_PATH, tmpdir); + CreateDirectoryA(tmpdir, NULL); + + strcpy(msitable, tmpdir); + strcat(msitable, "\\msitable.idt"); + + strcpy(msidb, tmpdir); + strcat(msidb, "\\msitest.msi"); + + r = MsiOpenDatabaseA(msidb, MSIDBOPEN_CREATE, &db); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); + + for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) + { + write_file(msitable, tests[i].data, tests[i].size); + + r = MsiDatabaseImportA(db, tmpdir, "msitable.idt"); + ok(r == tests[i].ret, " %u expected %u, got %u\n", i, tests[i].ret, r); + + r = MsiDatabaseCommit(db); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); + DeleteFileA(msitable); + } + + MsiCloseHandle(db); + DeleteFileA(msidb); + RemoveDirectoryA(tmpdir); +} + START_TEST(install) { DWORD len; @@ -6129,6 +6189,7 @@ START_TEST(install) test_sourcedirprop(); test_adminimage(); test_propcase(); + test_int_widths(); DeleteFileA(log_file);