A couple more fixes in RtlGetFullPathName_U.
Reverted my previous fix in RtlDosSearchPath_U, extension handling is supposed to be broken.
This commit is contained in:
parent
8d174d3f47
commit
509e4d175a
|
@ -262,12 +262,12 @@ ULONG WINAPI RtlDosSearchPath_U(LPCWSTR paths, LPCWSTR search, LPCWSTR ext,
|
||||||
if (type == RELATIVE_PATH)
|
if (type == RELATIVE_PATH)
|
||||||
{
|
{
|
||||||
ULONG allocated = 0, needed, filelen;
|
ULONG allocated = 0, needed, filelen;
|
||||||
WCHAR *p, *name = NULL;
|
WCHAR *name = NULL;
|
||||||
|
|
||||||
filelen = 1 /* for \ */ + strlenW(search) + 1 /* \0 */;
|
filelen = 1 /* for \ */ + strlenW(search) + 1 /* \0 */;
|
||||||
|
|
||||||
p = strrchrW( search, '.' );
|
/* Windows only checks for '.' without worrying about path components */
|
||||||
if (p && !strchrW( p, '\\' ) && !strchrW( p, '/')) ext = NULL;
|
if (strchrW( search, '.' )) ext = NULL;
|
||||||
if (ext != NULL) filelen += strlenW(ext);
|
if (ext != NULL) filelen += strlenW(ext);
|
||||||
|
|
||||||
while (*paths)
|
while (*paths)
|
||||||
|
@ -495,6 +495,7 @@ static ULONG get_full_path_helper(LPCWSTR name, LPWSTR buffer, ULONG size)
|
||||||
if (prev < buffer + mark) prev = p - 1;
|
if (prev < buffer + mark) prev = p - 1;
|
||||||
reqsize -= (p + 2 - prev) * sizeof(WCHAR);
|
reqsize -= (p + 2 - prev) * sizeof(WCHAR);
|
||||||
memmove(prev, p + 2, buffer + reqsize - prev + sizeof(WCHAR));
|
memmove(prev, p + 2, buffer + reqsize - prev + sizeof(WCHAR));
|
||||||
|
p = prev;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '\0':
|
case '\0':
|
||||||
|
@ -531,6 +532,7 @@ done:
|
||||||
DWORD WINAPI RtlGetFullPathName_U(const WCHAR* name, ULONG size, WCHAR* buffer,
|
DWORD WINAPI RtlGetFullPathName_U(const WCHAR* name, ULONG size, WCHAR* buffer,
|
||||||
WCHAR** file_part)
|
WCHAR** file_part)
|
||||||
{
|
{
|
||||||
|
WCHAR* ptr;
|
||||||
DWORD dosdev;
|
DWORD dosdev;
|
||||||
DWORD reqsize;
|
DWORD reqsize;
|
||||||
|
|
||||||
|
@ -558,17 +560,20 @@ DWORD WINAPI RtlGetFullPathName_U(const WCHAR* name, ULONG size, WCHAR* buffer,
|
||||||
reqsize = get_full_path_helper(name, buffer, size);
|
reqsize = get_full_path_helper(name, buffer, size);
|
||||||
if (reqsize > size)
|
if (reqsize > size)
|
||||||
{
|
{
|
||||||
LPWSTR tmp = RtlAllocateHeap(ntdll_get_process_heap(), 0, reqsize);
|
LPWSTR tmp = RtlAllocateHeap(ntdll_get_process_heap(), 0, reqsize);
|
||||||
reqsize = get_full_path_helper(name, tmp, reqsize) + sizeof(WCHAR);
|
reqsize = get_full_path_helper(name, tmp, reqsize);
|
||||||
|
if (reqsize > size) /* it may have worked the second time */
|
||||||
|
{
|
||||||
|
RtlFreeHeap(ntdll_get_process_heap(), 0, tmp);
|
||||||
|
return reqsize + sizeof(WCHAR);
|
||||||
|
}
|
||||||
|
memcpy( buffer, tmp, reqsize + sizeof(WCHAR) );
|
||||||
RtlFreeHeap(ntdll_get_process_heap(), 0, tmp);
|
RtlFreeHeap(ntdll_get_process_heap(), 0, tmp);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
/* find file part */
|
||||||
WCHAR* ptr;
|
if (file_part && (ptr = strrchrW(buffer, '\\')) != NULL && ptr >= buffer + 2 && *++ptr)
|
||||||
/* find file part */
|
*file_part = ptr;
|
||||||
if (file_part && (ptr = strrchrW(buffer, '\\')) != NULL && ptr >= buffer + 2 && *++ptr)
|
|
||||||
*file_part = ptr;
|
|
||||||
}
|
|
||||||
return reqsize;
|
return reqsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue