Remove trailing spaces from the filename in RtlGetFullPathName_U.
This commit is contained in:
parent
beaa084f6c
commit
c00b0b029a
|
@ -533,13 +533,18 @@ static const WCHAR *skip_unc_prefix( const WCHAR *ptr )
|
||||||
*/
|
*/
|
||||||
static ULONG get_full_path_helper(LPCWSTR name, LPWSTR buffer, ULONG size)
|
static ULONG get_full_path_helper(LPCWSTR name, LPWSTR buffer, ULONG size)
|
||||||
{
|
{
|
||||||
ULONG reqsize = 0, mark = 0, dep = 0, deplen;
|
ULONG reqsize = 0, mark = 0, dep = 0, deplen, name_len;
|
||||||
DOS_PATHNAME_TYPE type;
|
DOS_PATHNAME_TYPE type;
|
||||||
LPWSTR ins_str = NULL;
|
LPWSTR ins_str = NULL;
|
||||||
LPCWSTR ptr;
|
LPCWSTR ptr;
|
||||||
const UNICODE_STRING* cd;
|
const UNICODE_STRING* cd;
|
||||||
WCHAR tmp[4];
|
WCHAR tmp[4];
|
||||||
|
|
||||||
|
/* remove trailing spaces (yes, Windows really does that, don't ask) */
|
||||||
|
name_len = strlenW( name );
|
||||||
|
while (name_len && name[name_len-1] == ' ') name_len--;
|
||||||
|
if (!name_len) return 0;
|
||||||
|
|
||||||
RtlAcquirePebLock();
|
RtlAcquirePebLock();
|
||||||
|
|
||||||
if (NtCurrentTeb()->Tib.SubSystemTib) /* FIXME: hack */
|
if (NtCurrentTeb()->Tib.SubSystemTib) /* FIXME: hack */
|
||||||
|
@ -674,7 +679,7 @@ static ULONG get_full_path_helper(LPCWSTR name, LPWSTR buffer, ULONG size)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* enough space ? */
|
/* enough space ? */
|
||||||
deplen = strlenW(name + dep) * sizeof(WCHAR);
|
deplen = (name_len - dep) * sizeof(WCHAR);
|
||||||
if (reqsize + deplen + sizeof(WCHAR) > size)
|
if (reqsize + deplen + sizeof(WCHAR) > size)
|
||||||
{
|
{
|
||||||
/* not enough space, return need size (including terminating '\0') */
|
/* not enough space, return need size (including terminating '\0') */
|
||||||
|
@ -682,7 +687,8 @@ static ULONG get_full_path_helper(LPCWSTR name, LPWSTR buffer, ULONG size)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
memmove(buffer + reqsize / sizeof(WCHAR), name + dep, deplen + sizeof(WCHAR));
|
memmove(buffer + reqsize / sizeof(WCHAR), name + dep, deplen);
|
||||||
|
buffer[(reqsize + deplen) / sizeof(WCHAR)] = 0;
|
||||||
if (reqsize) memcpy(buffer, ins_str, reqsize);
|
if (reqsize) memcpy(buffer, ins_str, reqsize);
|
||||||
reqsize += deplen;
|
reqsize += deplen;
|
||||||
|
|
||||||
|
@ -737,6 +743,7 @@ 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) return 0;
|
||||||
if (reqsize > size)
|
if (reqsize > size)
|
||||||
{
|
{
|
||||||
LPWSTR tmp = RtlAllocateHeap(GetProcessHeap(), 0, reqsize);
|
LPWSTR tmp = RtlAllocateHeap(GetProcessHeap(), 0, reqsize);
|
||||||
|
|
|
@ -239,6 +239,7 @@ static void test_RtlGetFullPathName_U()
|
||||||
static const struct test tests[] =
|
static const struct test tests[] =
|
||||||
{
|
{
|
||||||
{ "c:/test", "c:\\test", "test"},
|
{ "c:/test", "c:\\test", "test"},
|
||||||
|
{ "c:/test ", "c:\\test", "test"},
|
||||||
{ "c:/TEST", "c:\\test", "test"},
|
{ "c:/TEST", "c:\\test", "test"},
|
||||||
{ "c:/test/file", "c:\\test\\file", "file"},
|
{ "c:/test/file", "c:\\test\\file", "file"},
|
||||||
{ "c:/test/././file", "c:\\test\\file", "file"},
|
{ "c:/test/././file", "c:\\test\\file", "file"},
|
||||||
|
|
Loading…
Reference in New Issue