Hans Leidekker : wininet: Avoid illegal filenames in CreateUrlCacheEntryW.
Alexandre Julliard
julliard at winehq.org
Mon Jan 19 08:59:01 CST 2009
Module: wine
Branch: master
Commit: b33792235eba3fe74aea7589a8c561cddb36ec75
URL: http://source.winehq.org/git/wine.git/?a=commit;h=b33792235eba3fe74aea7589a8c561cddb36ec75
Author: Hans Leidekker <hans at codeweavers.com>
Date: Mon Jan 19 11:40:45 2009 +0100
wininet: Avoid illegal filenames in CreateUrlCacheEntryW.
---
dlls/wininet/urlcache.c | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/dlls/wininet/urlcache.c b/dlls/wininet/urlcache.c
index d1d54ae..687290c 100644
--- a/dlls/wininet/urlcache.c
+++ b/dlls/wininet/urlcache.c
@@ -2313,9 +2313,26 @@ BOOL WINAPI CreateUrlCacheEntryW(
for (i = 0; i < 255; i++)
{
- static const WCHAR szFormat[] = {'[','%','u',']','%','s',0};
+ static const WCHAR szFormat[] = {'[','%','u',']','%','s',0};
HANDLE hFile;
+ WCHAR *p;
+
wsprintfW(lpszFileNameNoPath + countnoextension, szFormat, i, szExtension);
+ for (p = lpszFileNameNoPath + 1; *p; p++)
+ {
+ switch (*p)
+ {
+ case '<': case '>':
+ case ':': case '"':
+ case '/': case '\\':
+ case '|': case '?':
+ case '*':
+ *p = '_'; break;
+ default: break;
+ }
+ }
+ if (p[-1] == ' ' || p[-1] == '.') p[-1] = '_';
+
TRACE("Trying: %s\n", debugstr_w(lpszFileName));
hFile = CreateFileW(lpszFileName, GENERIC_READ, 0, NULL, CREATE_NEW, 0, NULL);
if (hFile != INVALID_HANDLE_VALUE)
More information about the wine-cvs
mailing list