Module: wine Branch: master Commit: efa6591fff772c7fc88f3dd26500610f55d6b551 URL: http://source.winehq.org/git/wine.git/?a=commit;h=efa6591fff772c7fc88f3dd265...
Author: James Hawkins truiken@gmail.com Date: Wed Mar 28 01:53:57 2007 -0500
setupapi: Don't allow relative paths in SetupCopyOEMInf.
---
dlls/setupapi/misc.c | 7 +++++++ dlls/setupapi/tests/misc.c | 32 ++++++++++++++++---------------- 2 files changed, 23 insertions(+), 16 deletions(-)
diff --git a/dlls/setupapi/misc.c b/dlls/setupapi/misc.c index b1845b7..8257828 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 cee4823..ea11a6c 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 */