Paul Vriens : odbccp32: Don't print *pcbPathOut as it can be NULL (Coverity ).

Alexandre Julliard julliard at wine.codeweavers.com
Wed Apr 4 12:32:27 CDT 2007


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

Author: Paul Vriens <Paul.Vriens.Wine at gmail.com>
Date:   Wed Apr  4 11:28:42 2007 +0200

odbccp32: Don't print *pcbPathOut as it can be NULL (Coverity).

---

 dlls/odbccp32/odbccp32.c   |    4 +-
 dlls/odbccp32/tests/misc.c |   51 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/dlls/odbccp32/odbccp32.c b/dlls/odbccp32/odbccp32.c
index 5289e14..0d4662b 100644
--- a/dlls/odbccp32/odbccp32.c
+++ b/dlls/odbccp32/odbccp32.c
@@ -523,7 +523,7 @@ BOOL WINAPI SQLInstallDriverManagerW(LPWSTR lpszPath, WORD cbPathMax,
     WCHAR path[MAX_PATH];
 
     clear_errors();
-    TRACE("(%p %d %d)\n", lpszPath, cbPathMax, *pcbPathOut);
+    TRACE("(%p %d %p)\n", lpszPath, cbPathMax, pcbPathOut);
 
     len = GetSystemDirectoryW(path, MAX_PATH);
 
@@ -546,7 +546,7 @@ BOOL WINAPI SQLInstallDriverManager(LPSTR lpszPath, WORD cbPathMax,
     WCHAR path[MAX_PATH];
 
     clear_errors();
-    TRACE("(%p %d %d)\n", lpszPath, cbPathMax, *pcbPathOut);
+    TRACE("(%p %d %p)\n", lpszPath, cbPathMax, pcbPathOut);
 
     ret = SQLInstallDriverManagerW(path, MAX_PATH, &cbOut);
     if (ret)
diff --git a/dlls/odbccp32/tests/misc.c b/dlls/odbccp32/tests/misc.c
index 0779b44..fdfecc0 100644
--- a/dlls/odbccp32/tests/misc.c
+++ b/dlls/odbccp32/tests/misc.c
@@ -74,8 +74,59 @@ static void test_SQLInstallerError(void)
     ok(sql_ret == SQL_SUCCESS_WITH_INFO, "SQLInstallerError(null addresses) failed with %d instead of SQL_SUCCESS_WITH_INFO\n", sql_ret);
 }
 
+static void test_SQLInstallDriverManager(void)
+{
+    BOOL bool_ret;
+    RETCODE sql_ret;
+    DWORD error_code;
+    CHAR target_path[MAX_PATH];
+    WORD path_out;
+
+    /* NULL check */
+    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 then 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);
+    sql_ret = SQLInstallerErrorW(1, &error_code, NULL, 0, NULL);
+    ok(bool_ret, "SQLInstallDriverManager unexpectedly failed\n");
+    ok(sql_ret == SQL_NO_DATA, "Expected SQL_NO_DATA, got %d\n", sql_ret);
+
+    path_out = 0xcafe;
+    bool_ret = SQLInstallDriverManager(target_path, MAX_PATH, &path_out);
+    sql_ret = SQLInstallerErrorW(1, &error_code, NULL, 0, NULL);
+    ok(bool_ret, "SQLInstallDriverManager unexpectedly failed\n");
+    ok(sql_ret == SQL_NO_DATA, "Expected SQL_NO_DATA, got %d\n", sql_ret);
+    /* path_out should in practice be less then 0xcafe */
+    ok(path_out != 0xcafe, "Expected path_out to show the correct amount of bytes\n");
+}
+
 START_TEST(misc)
 {
     test_SQLConfigMode();
     test_SQLInstallerError();
+    test_SQLInstallDriverManager();
 }




More information about the wine-cvs mailing list