From 4a7b5856daa5ce09bb52c2baa3d524a5ea1cae1b Mon Sep 17 00:00:00 2001 From: Andrew Eikum Date: Mon, 23 Mar 2015 09:56:58 -0500 Subject: [PATCH] oleaut32: Allow typelib filenames longer than MAX_PATH. --- dlls/oleaut32/typelib.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/dlls/oleaut32/typelib.c b/dlls/oleaut32/typelib.c index 54dbc0554b..b8325c0e02 100644 --- a/dlls/oleaut32/typelib.c +++ b/dlls/oleaut32/typelib.c @@ -3353,18 +3353,27 @@ static HRESULT TLB_ReadTypeLib(LPCWSTR pszFileName, LPWSTR pszPath, UINT cchPath h = CreateFileW(pszPath, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if(h != INVALID_HANDLE_VALUE){ - FILE_NAME_INFORMATION *info; - char data[MAX_PATH * sizeof(WCHAR) + sizeof(info->FileNameLength)]; + FILE_NAME_INFORMATION size_info; BOOL br; - info = (FILE_NAME_INFORMATION*)data; /* GetFileInformationByHandleEx returns the path of the file without * WOW64 redirection */ - br = GetFileInformationByHandleEx(h, FileNameInfo, data, sizeof(data)); - if(br){ - info->FileName[info->FileNameLength / sizeof(WCHAR)] = 0; - lstrcpynW(pszPath + 2, info->FileName, cchPath - 2); + br = GetFileInformationByHandleEx(h, FileNameInfo, &size_info, sizeof(size_info)); + if(br || GetLastError() == ERROR_MORE_DATA){ + FILE_NAME_INFORMATION *info; + DWORD size = sizeof(*info) + size_info.FileNameLength + sizeof(WCHAR); + + info = HeapAlloc(GetProcessHeap(), 0, size); + + br = GetFileInformationByHandleEx(h, FileNameInfo, info, size); + if(br){ + info->FileName[info->FileNameLength / sizeof(WCHAR)] = 0; + lstrcpynW(pszPath + 2, info->FileName, cchPath - 2); + } + + HeapFree(GetProcessHeap(), 0, info); } + CloseHandle(h); }