Louis Lenders : kernel32: Fix GetTempFileName with invalid path.
Alexandre Julliard
julliard at winehq.org
Thu Dec 2 16:30:53 CST 2010
Module: wine
Branch: stable
Commit: d7c7c2f43d54c9475e0838e77c1af3b910f0320d
URL: http://source.winehq.org/git/wine.git/?a=commit;h=d7c7c2f43d54c9475e0838e77c1af3b910f0320d
Author: Louis Lenders <xerox_xerox2000 at yahoo.co.uk>
Date: Wed Oct 20 20:27:38 2010 +0200
kernel32: Fix GetTempFileName with invalid path.
Found by Oskar Eisemuth.
(cherry picked from commit 8819ae1e66fb0d4181594510431eee7c8d158af0)
---
dlls/kernel32/path.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/dlls/kernel32/path.c b/dlls/kernel32/path.c
index 0e69f91..6f97b3a 100644
--- a/dlls/kernel32/path.c
+++ b/dlls/kernel32/path.c
@@ -660,6 +660,7 @@ UINT WINAPI GetTempFileNameW( LPCWSTR path, LPCWSTR prefix, UINT unique, LPWSTR
int i;
LPWSTR p;
+ DWORD attr;
if ( !path || !buffer )
{
@@ -667,6 +668,15 @@ UINT WINAPI GetTempFileNameW( LPCWSTR path, LPCWSTR prefix, UINT unique, LPWSTR
return 0;
}
+ /* ensure that the provided directory exists */
+ attr = GetFileAttributesW(path);
+ if (attr == INVALID_FILE_ATTRIBUTES || !(attr & FILE_ATTRIBUTE_DIRECTORY))
+ {
+ TRACE("path not found %s\n", debugstr_w(path));
+ SetLastError( ERROR_DIRECTORY );
+ return 0;
+ }
+
strcpyW( buffer, path );
p = buffer + strlenW(buffer);
More information about the wine-cvs
mailing list