wininet: Check URLCache_LocalFileNameToPathW() return values in CreateUrlCacheEntryW().
authorHenri Verbeet <hverbeet@codeweavers.com>
Thu, 23 Sep 2010 09:48:04 +0000 (11:48 +0200)
committerAlexandre Julliard <julliard@winehq.org>
Thu, 23 Sep 2010 10:06:38 +0000 (12:06 +0200)
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

index 2fe488a029feea5f82b48632c010f41901d85032..a220e330399e16c36f8164f72322fda540fee59d 100644 (file)
@@ -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);