kernel32: Don't use uninitialized ofs->szPathName in OpenFile.

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2019-09-27 20:00:32 +02:00 committed by Alexandre Julliard
parent 78f6d67153
commit 392648dda2

View file

@ -1166,6 +1166,7 @@ HFILE WINAPI OpenFile( LPCSTR name, OFSTRUCT *ofs, UINT mode )
HANDLE handle;
FILETIME filetime;
WORD filedatetime[2];
DWORD len;
if (!ofs) return HFILE_ERROR;
@ -1201,7 +1202,13 @@ HFILE WINAPI OpenFile( LPCSTR name, OFSTRUCT *ofs, UINT mode )
/* the watcom 10.6 IDE relies on a valid path returned in ofs->szPathName
Are there any cases where getting the path here is wrong?
Uwe Bonnes 1997 Apr 2 */
if (!GetFullPathNameA( name, sizeof(ofs->szPathName), ofs->szPathName, NULL )) goto error;
len = GetFullPathNameA( name, sizeof(ofs->szPathName), ofs->szPathName, NULL );
if (!len) goto error;
if (len >= sizeof(ofs->szPathName))
{
SetLastError(ERROR_INVALID_DATA);
goto error;
}
/* OF_PARSE simply fills the structure */
@ -1224,8 +1231,13 @@ HFILE WINAPI OpenFile( LPCSTR name, OFSTRUCT *ofs, UINT mode )
{
/* Now look for the file */
if (!SearchPathA( NULL, name, NULL, sizeof(ofs->szPathName), ofs->szPathName, NULL ))
len = SearchPathA( NULL, name, NULL, sizeof(ofs->szPathName), ofs->szPathName, NULL );
if (!len) goto error;
if (len >= sizeof(ofs->szPathName))
{
SetLastError(ERROR_INVALID_DATA);
goto error;
}
TRACE("found %s\n", debugstr_a(ofs->szPathName) );