Module: wine Branch: master Commit: 77fa32a8327b09a33080f78e2ce69123bbd3083c URL: http://source.winehq.org/git/wine.git/?a=commit;h=77fa32a8327b09a33080f78e2c...
Author: Paul Vriens Paul.Vriens.Wine@gmail.com Date: Fri May 15 14:48:28 2009 +0200
setupapi: Fix passing a NULL parameter (Coverity).
---
dlls/setupapi/misc.c | 6 ++++++ dlls/setupapi/tests/misc.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/dlls/setupapi/misc.c b/dlls/setupapi/misc.c index 36d52ba..a9efa2a 100644 --- a/dlls/setupapi/misc.c +++ b/dlls/setupapi/misc.c @@ -1139,6 +1139,12 @@ BOOL WINAPI SetupUninstallOEMInfW( PCWSTR inf_file, DWORD flags, PVOID reserved
TRACE("%s, 0x%08x, %p\n", debugstr_w(inf_file), flags, reserved);
+ if (!inf_file) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + if (!GetWindowsDirectoryW( target, sizeof(target)/sizeof(WCHAR) )) return FALSE;
strcatW( target, infW ); diff --git a/dlls/setupapi/tests/misc.c b/dlls/setupapi/tests/misc.c index e110e22..4b8bd03 100644 --- a/dlls/setupapi/tests/misc.c +++ b/dlls/setupapi/tests/misc.c @@ -46,6 +46,7 @@ static CHAR CURR_DIR[MAX_PATH]; static BOOL (WINAPI *pSetupGetFileCompressionInfoExA)(PCSTR, PSTR, DWORD, PDWORD, PDWORD, PDWORD, PUINT); static BOOL (WINAPI *pSetupCopyOEMInfA)(PCSTR, PCSTR, DWORD, DWORD, PSTR, DWORD, PDWORD, PSTR *); static BOOL (WINAPI *pSetupQueryInfOriginalFileInformationA)(PSP_INF_INFORMATION, UINT, PSP_ALTPLATFORM_INFO, PSP_ORIGINAL_FILE_INFO_A); +static BOOL (WINAPI *pSetupUninstallOEMInfA)(PCSTR, DWORD, PVOID);
static void create_inf_file(LPCSTR filename) { @@ -581,6 +582,32 @@ static void test_SetupDecompressOrCopyFile(void) DeleteFileA(source); }
+static void test_SetupUninstallOEMInf(void) +{ + BOOL ret; + + SetLastError(0xdeadbeef); + ret = pSetupUninstallOEMInfA(NULL, 0, NULL); + ok(!ret, "Expected failure\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = pSetupUninstallOEMInfA("", 0, NULL); + todo_wine + { + ok(!ret, "Expected failure\n"); + ok(GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); + } + + SetLastError(0xdeadbeef); + ret = pSetupUninstallOEMInfA("nonexistent.inf", 0, NULL); + todo_wine + { + ok(!ret, "Expected failure\n"); + ok(GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); + } +} + START_TEST(misc) { HMODULE hsetupapi = GetModuleHandle("setupapi.dll"); @@ -588,6 +615,7 @@ START_TEST(misc) pSetupGetFileCompressionInfoExA = (void*)GetProcAddress(hsetupapi, "SetupGetFileCompressionInfoExA"); pSetupCopyOEMInfA = (void*)GetProcAddress(hsetupapi, "SetupCopyOEMInfA"); pSetupQueryInfOriginalFileInformationA = (void*)GetProcAddress(hsetupapi, "SetupQueryInfOriginalFileInformationA"); + pSetupUninstallOEMInfA = (void*)GetProcAddress(hsetupapi, "SetupUninstallOEMInfA");
GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
@@ -604,4 +632,9 @@ START_TEST(misc) win_skip("SetupGetFileCompressionInfoExA is not available\n");
test_SetupDecompressOrCopyFile(); + + if (pSetupUninstallOEMInfA) + test_SetupUninstallOEMInf(); + else + win_skip("SetupUninstallOEMInfA is not available\n"); }