Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
6d270a1d
Commit
6d270a1d
authored
Dec 21, 2009
by
Nikolay Sivov
Committed by
Alexandre Julliard
Dec 22, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Fix SearchPath parameter validation with tests.
parent
08a778c5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
2 deletions
+91
-2
path.c
dlls/kernel32/path.c
+14
-2
path.c
dlls/kernel32/tests/path.c
+77
-0
No files found.
dlls/kernel32/path.c
View file @
6d270a1d
...
@@ -758,6 +758,12 @@ DWORD WINAPI SearchPathW( LPCWSTR path, LPCWSTR name, LPCWSTR ext, DWORD buflen,
...
@@ -758,6 +758,12 @@ DWORD WINAPI SearchPathW( LPCWSTR path, LPCWSTR name, LPCWSTR ext, DWORD buflen,
{
{
DWORD
ret
=
0
;
DWORD
ret
=
0
;
if
(
!
name
||
!
name
[
0
])
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
0
;
}
/* If the name contains an explicit path, ignore the path */
/* If the name contains an explicit path, ignore the path */
if
(
contains_pathW
(
name
))
if
(
contains_pathW
(
name
))
...
@@ -827,11 +833,17 @@ DWORD WINAPI SearchPathW( LPCWSTR path, LPCWSTR name, LPCWSTR ext, DWORD buflen,
...
@@ -827,11 +833,17 @@ DWORD WINAPI SearchPathW( LPCWSTR path, LPCWSTR name, LPCWSTR ext, DWORD buflen,
DWORD
WINAPI
SearchPathA
(
LPCSTR
path
,
LPCSTR
name
,
LPCSTR
ext
,
DWORD
WINAPI
SearchPathA
(
LPCSTR
path
,
LPCSTR
name
,
LPCSTR
ext
,
DWORD
buflen
,
LPSTR
buffer
,
LPSTR
*
lastpart
)
DWORD
buflen
,
LPSTR
buffer
,
LPSTR
*
lastpart
)
{
{
WCHAR
*
pathW
=
NULL
,
*
nameW
=
NULL
,
*
extW
=
NULL
;
WCHAR
*
pathW
=
NULL
,
*
nameW
,
*
extW
=
NULL
;
WCHAR
bufferW
[
MAX_PATH
];
WCHAR
bufferW
[
MAX_PATH
];
DWORD
ret
;
DWORD
ret
;
if
(
!
name
||
!
(
nameW
=
FILE_name_AtoW
(
name
,
FALSE
)))
return
0
;
if
(
!
name
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
0
;
}
if
(
!
(
nameW
=
FILE_name_AtoW
(
name
,
FALSE
)))
return
0
;
if
(
path
&&
!
(
pathW
=
FILE_name_AtoW
(
path
,
TRUE
)))
return
0
;
if
(
path
&&
!
(
pathW
=
FILE_name_AtoW
(
path
,
TRUE
)))
return
0
;
if
(
ext
&&
!
(
extW
=
FILE_name_AtoW
(
ext
,
TRUE
)))
if
(
ext
&&
!
(
extW
=
FILE_name_AtoW
(
ext
,
TRUE
)))
...
...
dlls/kernel32/tests/path.c
View file @
6d270a1d
...
@@ -57,6 +57,9 @@ static DWORD (WINAPI *pGetLongPathNameW)(LPWSTR,LPWSTR,DWORD);
...
@@ -57,6 +57,9 @@ static DWORD (WINAPI *pGetLongPathNameW)(LPWSTR,LPWSTR,DWORD);
static
BOOL
(
WINAPI
*
pNeedCurrentDirectoryForExePathA
)(
LPCSTR
);
static
BOOL
(
WINAPI
*
pNeedCurrentDirectoryForExePathA
)(
LPCSTR
);
static
BOOL
(
WINAPI
*
pNeedCurrentDirectoryForExePathW
)(
LPCWSTR
);
static
BOOL
(
WINAPI
*
pNeedCurrentDirectoryForExePathW
)(
LPCWSTR
);
static
DWORD
(
WINAPI
*
pSearchPathA
)(
LPCSTR
,
LPCSTR
,
LPCSTR
,
DWORD
,
LPSTR
,
LPSTR
*
);
static
DWORD
(
WINAPI
*
pSearchPathW
)(
LPCWSTR
,
LPCWSTR
,
LPCWSTR
,
DWORD
,
LPWSTR
,
LPWSTR
*
);
/* a structure to deal with wine todos somewhat cleanly */
/* a structure to deal with wine todos somewhat cleanly */
typedef
struct
{
typedef
struct
{
DWORD
shortlen
;
DWORD
shortlen
;
...
@@ -1456,6 +1459,76 @@ static void test_drive_letter_case(void)
...
@@ -1456,6 +1459,76 @@ static void test_drive_letter_case(void)
#undef is_upper_case_letter
#undef is_upper_case_letter
}
}
static
void
test_SearchPathA
(
void
)
{
CHAR
pathA
[
MAX_PATH
],
fileA
[]
=
""
,
buffA
[
MAX_PATH
];
CHAR
*
ptrA
=
NULL
;
DWORD
ret
;
if
(
!
pSearchPathA
)
{
win_skip
(
"SearchPathA isn't available
\n
"
);
return
;
}
GetWindowsDirectoryA
(
pathA
,
sizeof
(
pathA
)
/
sizeof
(
CHAR
));
/* NULL filename */
SetLastError
(
0xdeadbeef
);
ret
=
pSearchPathA
(
pathA
,
NULL
,
NULL
,
sizeof
(
buffA
)
/
sizeof
(
CHAR
),
buffA
,
&
ptrA
);
ok
(
ret
==
0
,
"Expected failure, got %d
\n
"
,
ret
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"Expected ERROR_INVALID_PARAMETER, got %x
\n
"
,
GetLastError
());
/* empty filename */
SetLastError
(
0xdeadbeef
);
ret
=
pSearchPathA
(
pathA
,
fileA
,
NULL
,
sizeof
(
buffA
)
/
sizeof
(
CHAR
),
buffA
,
&
ptrA
);
ok
(
ret
==
0
,
"Expected failure, got %d
\n
"
,
ret
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
||
broken
(
GetLastError
()
==
ERROR_FILE_NOT_FOUND
)
/* win9x */
,
"Expected ERROR_INVALID_PARAMETER, got %x
\n
"
,
GetLastError
());
}
static
void
test_SearchPathW
(
void
)
{
WCHAR
pathW
[
MAX_PATH
],
fileW
[]
=
{
0
},
buffW
[
MAX_PATH
];
WCHAR
*
ptrW
=
NULL
;
DWORD
ret
;
if
(
!
pSearchPathW
)
{
win_skip
(
"SearchPathW isn't available
\n
"
);
return
;
}
/* SearchPathW is a stub on win9x and doesn't return sane error,
so quess if it's implemented indirectly */
SetLastError
(
0xdeadbeef
);
GetWindowsDirectoryW
(
pathW
,
sizeof
(
pathW
)
/
sizeof
(
WCHAR
));
if
(
GetLastError
()
==
ERROR_CALL_NOT_IMPLEMENTED
)
{
win_skip
(
"SearchPathW not implemented
\n
"
);
return
;
}
if
(
0
)
{
/* NULL filename, crashes on nt4 */
SetLastError
(
0xdeadbeef
);
ret
=
pSearchPathW
(
pathW
,
NULL
,
NULL
,
sizeof
(
buffW
)
/
sizeof
(
WCHAR
),
buffW
,
&
ptrW
);
ok
(
ret
==
0
,
"Expected failure, got %d
\n
"
,
ret
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"Expected ERROR_INVALID_PARAMETER, got %x
\n
"
,
GetLastError
());
}
/* empty filename */
SetLastError
(
0xdeadbeef
);
ret
=
pSearchPathW
(
pathW
,
fileW
,
NULL
,
sizeof
(
buffW
)
/
sizeof
(
WCHAR
),
buffW
,
&
ptrW
);
ok
(
ret
==
0
,
"Expected failure, got %d
\n
"
,
ret
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"Expected ERROR_INVALID_PARAMETER, got %x
\n
"
,
GetLastError
());
}
static
void
init_pointers
(
void
)
static
void
init_pointers
(
void
)
{
{
HMODULE
hKernel32
=
GetModuleHandleA
(
"kernel32.dll"
);
HMODULE
hKernel32
=
GetModuleHandleA
(
"kernel32.dll"
);
...
@@ -1465,6 +1538,8 @@ static void init_pointers(void)
...
@@ -1465,6 +1538,8 @@ static void init_pointers(void)
MAKEFUNC
(
GetLongPathNameW
);
MAKEFUNC
(
GetLongPathNameW
);
MAKEFUNC
(
NeedCurrentDirectoryForExePathA
);
MAKEFUNC
(
NeedCurrentDirectoryForExePathA
);
MAKEFUNC
(
NeedCurrentDirectoryForExePathW
);
MAKEFUNC
(
NeedCurrentDirectoryForExePathW
);
MAKEFUNC
(
SearchPathA
);
MAKEFUNC
(
SearchPathW
);
#undef MAKEFUNC
#undef MAKEFUNC
}
}
...
@@ -1493,4 +1568,6 @@ START_TEST(path)
...
@@ -1493,4 +1568,6 @@ START_TEST(path)
test_NeedCurrentDirectoryForExePathA
();
test_NeedCurrentDirectoryForExePathA
();
test_NeedCurrentDirectoryForExePathW
();
test_NeedCurrentDirectoryForExePathW
();
test_drive_letter_case
();
test_drive_letter_case
();
test_SearchPathA
();
test_SearchPathW
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment