UNC Pathname handling
Paul Vriens
paul.vriens.wine at gmail.com
Fri Dec 11 07:20:41 CST 2009
On 12/11/2009 02:00 PM, Alexandre Hardy wrote:
> DWORD WINAPI GetLongPathNameW( LPCWSTR shortpath, LPWSTR longpath, DWORD longlen )
> {
> - WCHAR tmplongpath[MAX_PATHNAME_LEN];
> + LPWSTR tmplongpath;
> LPCWSTR p;
> DWORD sp = 0, lp = 0;
> DWORD tmplen;
> @@ -309,13 +310,44 @@ DWORD WINAPI GetLongPathNameW( LPCWSTR shortpath, LPWSTR longpath, DWORD longlen
> return 0;
> }
>
> + if (!(tmplongpath = (WCHAR *)HeapAlloc( GetProcessHeap(), 0, MAX_LONGPATHNAME_LEN * sizeof(WCHAR) ))) {
> + SetLastError( ERROR_OUTOFMEMORY );
> + return 0;
> + }
> +
This is not really dynamic, is it? You are still allocating that same
amount. Now, I'm not sure how to fix this as you need some way of
calculating the needed length in any case. Is that cast necessary btw?
Now as I understand the function it can only be a maximum of 32767 when
you use '\\?\', right? If so then this allocation should only be needed
in the '\\?\' case. This however is something you have to add tests for
as well. So create a path > MAX_PATH (if that's possible as I guess the
path/file has to exist as well) and see what is returned on Windows.
As you are now covering the '\\?\' case the ERR should go down as well
and should maybe be a FIXME now?
--
Cheers,
Paul.
More information about the wine-devel
mailing list