[PATCH 3/4] wininet: Check URLCache_LocalFileNameToPathW() return values in CreateUrlCacheEntryW().

Henri Verbeet hverbeet at codeweavers.com
Thu Sep 23 04:48:04 CDT 2010


It would be unfortunate if a long file name would cause us to open a file
based on mostly uninitialized data and write the contents of some random
webpage into it.
---
 dlls/wininet/urlcache.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/dlls/wininet/urlcache.c b/dlls/wininet/urlcache.c
index 2fe488a..a220e33 100644
--- a/dlls/wininet/urlcache.c
+++ b/dlls/wininet/urlcache.c
@@ -2330,7 +2330,13 @@ BOOL WINAPI CreateUrlCacheEntryW(
     CacheDir = (BYTE)(rand() % pHeader->DirectoryCount);
 
     lBufferSize = MAX_PATH * sizeof(WCHAR);
-    URLCache_LocalFileNameToPathW(pContainer, pHeader, szFile, CacheDir, lpszFileName, &lBufferSize);
+    if (!URLCache_LocalFileNameToPathW(pContainer, pHeader, szFile, CacheDir, lpszFileName, &lBufferSize))
+    {
+        WARN("Failed to get full path for filename %s, needed %u bytes.\n",
+                debugstr_a(szFile), lBufferSize);
+        URLCacheContainer_UnlockIndex(pContainer, pHeader);
+        return FALSE;
+    }
 
     URLCacheContainer_UnlockIndex(pContainer, pHeader);
 
-- 
1.7.2.2




More information about the wine-patches mailing list