From b234bb49ff8f67acc287e9601739632ab743c03f Mon Sep 17 00:00:00 2001 From: Alexandre Goujon Date: Mon, 13 Sep 2010 13:56:56 +0200 Subject: [PATCH] odbccp32: Fix SQLInstallDriverManager{,W}. --- dlls/odbccp32/odbccp32.c | 12 ++++++++++-- dlls/odbccp32/tests/misc.c | 5 ----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/dlls/odbccp32/odbccp32.c b/dlls/odbccp32/odbccp32.c index 0d4662bb724..d34920380f3 100644 --- a/dlls/odbccp32/odbccp32.c +++ b/dlls/odbccp32/odbccp32.c @@ -522,9 +522,13 @@ BOOL WINAPI SQLInstallDriverManagerW(LPWSTR lpszPath, WORD cbPathMax, UINT len; WCHAR path[MAX_PATH]; - clear_errors(); TRACE("(%p %d %p)\n", lpszPath, cbPathMax, pcbPathOut); + if (cbPathMax < MAX_PATH) + return FALSE; + + clear_errors(); + len = GetSystemDirectoryW(path, MAX_PATH); if (pcbPathOut) @@ -545,9 +549,13 @@ BOOL WINAPI SQLInstallDriverManager(LPSTR lpszPath, WORD cbPathMax, WORD len, cbOut = 0; WCHAR path[MAX_PATH]; - clear_errors(); TRACE("(%p %d %p)\n", lpszPath, cbPathMax, pcbPathOut); + if (cbPathMax < MAX_PATH) + return FALSE; + + clear_errors(); + ret = SQLInstallDriverManagerW(path, MAX_PATH, &cbOut); if (ret) { diff --git a/dlls/odbccp32/tests/misc.c b/dlls/odbccp32/tests/misc.c index 044846cc7d4..40846e5c9ef 100644 --- a/dlls/odbccp32/tests/misc.c +++ b/dlls/odbccp32/tests/misc.c @@ -86,28 +86,23 @@ static void test_SQLInstallDriverManager(void) bool_ret = SQLInstallDriverManager(NULL, 0, NULL); sql_ret = SQLInstallerErrorW(1, &error_code, NULL, 0, NULL); ok(!bool_ret, "SQLInstallDriverManager unexpectedly succeeded\n"); - todo_wine ok(sql_ret == SQL_SUCCESS_WITH_INFO && error_code == ODBC_ERROR_INVALID_BUFF_LEN, "Expected SQLInstallDriverManager to fail with ODBC_ERROR_INVALID_BUFF_LEN\n"); /* Length smaller than MAX_PATH */ bool_ret = SQLInstallDriverManager(target_path, MAX_PATH / 2, NULL); sql_ret = SQLInstallerErrorW(1, &error_code, NULL, 0, NULL); - todo_wine { ok(!bool_ret, "SQLInstallDriverManager unexpectedly succeeded\n"); ok(sql_ret == SQL_SUCCESS_WITH_INFO && error_code == ODBC_ERROR_INVALID_BUFF_LEN, "Expected SQLInstallDriverManager to fail with ODBC_ERROR_INVALID_BUFF_LEN\n"); - } path_out = 0xcafe; bool_ret = SQLInstallDriverManager(target_path, MAX_PATH / 2, &path_out); sql_ret = SQLInstallerErrorW(1, &error_code, NULL, 0, NULL); - todo_wine { ok(!bool_ret, "SQLInstallDriverManager unexpectedly succeeded\n"); ok(sql_ret == SQL_SUCCESS_WITH_INFO && error_code == ODBC_ERROR_INVALID_BUFF_LEN, "Expected SQLInstallDriverManager to fail with ODBC_ERROR_INVALID_BUFF_LEN\n"); ok(path_out == 0xcafe, "Expected path_out to not have changed\n"); - } /* Length OK */ bool_ret = SQLInstallDriverManager(target_path, MAX_PATH, NULL);