diff --git a/dlls/setupapi/misc.c b/dlls/setupapi/misc.c index b1845b7e5c..825782856d 100644 --- a/dlls/setupapi/misc.c +++ b/dlls/setupapi/misc.c @@ -944,6 +944,13 @@ BOOL WINAPI SetupCopyOEMInfW( PCWSTR source, PCWSTR location, return FALSE; } + /* check for a relative path */ + if (!(*source == '\\' || (*source && source[1] == ':'))) + { + SetLastError(ERROR_FILE_NOT_FOUND); + return FALSE; + } + if (!GetWindowsDirectoryW( target, sizeof(target)/sizeof(WCHAR) )) return FALSE; strcatW( target, inf_oem ); diff --git a/dlls/setupapi/tests/misc.c b/dlls/setupapi/tests/misc.c index cee4823311..ea11a6cfd3 100644 --- a/dlls/setupapi/tests/misc.c +++ b/dlls/setupapi/tests/misc.c @@ -118,16 +118,22 @@ static void test_SetupCopyOEMInf(void) SetLastError(0xdeadbeef); res = SetupCopyOEMInf("", NULL, 0, SP_COPY_NOOVERWRITE, NULL, 0, NULL, NULL); ok(res == FALSE, "Expected FALSE, got %d\n", res); - todo_wine - { - ok(GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError()); - } + ok(GetLastError() == ERROR_FILE_NOT_FOUND, + "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError()); - /* try nonexistent SourceInfFileName */ + /* try a relative nonexistent SourceInfFileName */ SetLastError(0xdeadbeef); res = SetupCopyOEMInf("nonexistent", NULL, 0, SP_COPY_NOOVERWRITE, NULL, 0, NULL, NULL); ok(res == FALSE, "Expected FALSE, got %d\n", res); + ok(GetLastError() == ERROR_FILE_NOT_FOUND, + "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError()); + + /* try an absolute nonexistent SourceInfFileName */ + lstrcpy(path, CURR_DIR); + lstrcat(path, "\\nonexistent"); + SetLastError(0xdeadbeef); + res = SetupCopyOEMInf(path, NULL, 0, SP_COPY_NOOVERWRITE, NULL, 0, NULL, NULL); + ok(res == FALSE, "Expected FALSE, got %d\n", res); todo_wine { ok(GetLastError() == ERROR_FILE_NOT_FOUND, @@ -140,11 +146,8 @@ static void test_SetupCopyOEMInf(void) SetLastError(0xdeadbeef); res = SetupCopyOEMInf(toolong, NULL, 0, SP_COPY_NOOVERWRITE, NULL, 0, NULL, NULL); ok(res == FALSE, "Expected FALSE, got %d\n", res); - todo_wine - { - ok(GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError()); - } + ok(GetLastError() == ERROR_FILE_NOT_FOUND, + "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError()); get_temp_filename(tmpfile); create_inf_file(tmpfile); @@ -153,11 +156,8 @@ static void test_SetupCopyOEMInf(void) SetLastError(0xdeadbeef); res = SetupCopyOEMInf(tmpfile, NULL, 0, SP_COPY_NOOVERWRITE, NULL, 0, NULL, NULL); ok(res == FALSE, "Expected FALSE, got %d\n", res); - todo_wine - { - ok(GetLastError() == ERROR_FILE_NOT_FOUND, - "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError()); - } + ok(GetLastError() == ERROR_FILE_NOT_FOUND, + "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError()); ok(file_exists(tmpfile), "Expected tmpfile to exist\n"); /* try SP_COPY_REPLACEONLY, dest does not exist */