Module: wine Branch: master Commit: 7782e8188795ddc4cbdb51d81e1d5aa7200f6a33 URL: http://source.winehq.org/git/wine.git/?a=commit;h=7782e8188795ddc4cbdb51d81e...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Thu Sep 23 11:48:04 2010 +0200
wininet: Check URLCache_LocalFileNameToPathW() return values in CreateUrlCacheEntryW().
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);