Commit 77fa32a8 authored by Paul Vriens's avatar Paul Vriens Committed by Alexandre Julliard

setupapi: Fix passing a NULL parameter (Coverity).

parent 6a025c5a
...@@ -1139,6 +1139,12 @@ BOOL WINAPI SetupUninstallOEMInfW( PCWSTR inf_file, DWORD flags, PVOID reserved ...@@ -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); 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; if (!GetWindowsDirectoryW( target, sizeof(target)/sizeof(WCHAR) )) return FALSE;
strcatW( target, infW ); strcatW( target, infW );
......
...@@ -46,6 +46,7 @@ static CHAR CURR_DIR[MAX_PATH]; ...@@ -46,6 +46,7 @@ static CHAR CURR_DIR[MAX_PATH];
static BOOL (WINAPI *pSetupGetFileCompressionInfoExA)(PCSTR, PSTR, DWORD, PDWORD, PDWORD, PDWORD, PUINT); 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 *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 *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) static void create_inf_file(LPCSTR filename)
{ {
...@@ -581,6 +582,32 @@ static void test_SetupDecompressOrCopyFile(void) ...@@ -581,6 +582,32 @@ static void test_SetupDecompressOrCopyFile(void)
DeleteFileA(source); 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) START_TEST(misc)
{ {
HMODULE hsetupapi = GetModuleHandle("setupapi.dll"); HMODULE hsetupapi = GetModuleHandle("setupapi.dll");
...@@ -588,6 +615,7 @@ START_TEST(misc) ...@@ -588,6 +615,7 @@ START_TEST(misc)
pSetupGetFileCompressionInfoExA = (void*)GetProcAddress(hsetupapi, "SetupGetFileCompressionInfoExA"); pSetupGetFileCompressionInfoExA = (void*)GetProcAddress(hsetupapi, "SetupGetFileCompressionInfoExA");
pSetupCopyOEMInfA = (void*)GetProcAddress(hsetupapi, "SetupCopyOEMInfA"); pSetupCopyOEMInfA = (void*)GetProcAddress(hsetupapi, "SetupCopyOEMInfA");
pSetupQueryInfOriginalFileInformationA = (void*)GetProcAddress(hsetupapi, "SetupQueryInfOriginalFileInformationA"); pSetupQueryInfOriginalFileInformationA = (void*)GetProcAddress(hsetupapi, "SetupQueryInfOriginalFileInformationA");
pSetupUninstallOEMInfA = (void*)GetProcAddress(hsetupapi, "SetupUninstallOEMInfA");
GetCurrentDirectoryA(MAX_PATH, CURR_DIR); GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
...@@ -604,4 +632,9 @@ START_TEST(misc) ...@@ -604,4 +632,9 @@ START_TEST(misc)
win_skip("SetupGetFileCompressionInfoExA is not available\n"); win_skip("SetupGetFileCompressionInfoExA is not available\n");
test_SetupDecompressOrCopyFile(); test_SetupDecompressOrCopyFile();
if (pSetupUninstallOEMInfA)
test_SetupUninstallOEMInf();
else
win_skip("SetupUninstallOEMInfA is not available\n");
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment