mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-07 06:34:06 +00:00
krnl386.exe: Fix VxD filename format checks in __wine_vxd_open().
__wine_vxd_open() has several bugs. If filenameW doesn't end in ".vxd", it is wrongly allowed to be over 8 characters long. If it does end in ".vxd", then a maximum length filename, eg. "12345678.vxd", always gets misdetected as being too long, as: "lstrlenW( filenameW ) >= ARRAY_SIZE(name) - 4" becomes 12 >= 12. Rather do the checks for maximum filename length when we detect the filename format. Signed-off-by: Damjan Jovanovic <damjan.jov@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
bf8c5afef1
commit
fc4726c225
|
@ -136,29 +136,34 @@ done:
|
||||||
/* load a VxD and return a file handle to it */
|
/* load a VxD and return a file handle to it */
|
||||||
HANDLE __wine_vxd_open( LPCWSTR filenameW, DWORD access, SECURITY_ATTRIBUTES *sa )
|
HANDLE __wine_vxd_open( LPCWSTR filenameW, DWORD access, SECURITY_ATTRIBUTES *sa )
|
||||||
{
|
{
|
||||||
static const WCHAR dotVxDW[] = {'.','v','x','d',0};
|
|
||||||
int i;
|
int i;
|
||||||
HANDLE handle;
|
HANDLE handle;
|
||||||
HMODULE module;
|
HMODULE module;
|
||||||
WCHAR *p, name[16];
|
WCHAR *p, name[13];
|
||||||
|
|
||||||
/* normalize the filename */
|
/* normalize the filename */
|
||||||
|
|
||||||
if (lstrlenW( filenameW ) >= ARRAY_SIZE(name) - 4 ||
|
if (wcschr( filenameW, '/' ) || wcschr( filenameW, '\\' ))
|
||||||
wcschr( filenameW, '/' ) || wcschr( filenameW, '\\' ))
|
{
|
||||||
|
SetLastError( ERROR_FILE_NOT_FOUND );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
p = wcschr( filenameW, '.' );
|
||||||
|
if (!p && lstrlenW( filenameW ) <= 8)
|
||||||
|
{
|
||||||
|
wcscpy( name, filenameW );
|
||||||
|
wcscat( name, L".vxd" );
|
||||||
|
}
|
||||||
|
else if (p && !wcsicmp( p, L".vxd" ) && lstrlenW( filenameW ) <= 12) /* existing extension has to be .vxd */
|
||||||
|
{
|
||||||
|
wcscpy( name, filenameW );
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
SetLastError( ERROR_FILE_NOT_FOUND );
|
SetLastError( ERROR_FILE_NOT_FOUND );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
lstrcpyW( name, filenameW );
|
|
||||||
wcslwr( name );
|
wcslwr( name );
|
||||||
p = wcschr( name, '.' );
|
|
||||||
if (!p) lstrcatW( name, dotVxDW );
|
|
||||||
else if (wcsicmp( p, dotVxDW )) /* existing extension has to be .vxd */
|
|
||||||
{
|
|
||||||
SetLastError( ERROR_FILE_NOT_FOUND );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* try to load the module first */
|
/* try to load the module first */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue