vrclient: Improve relative path handling in vrclient_dos_to_unix_path().

CW-Bug-Id: #24798
This commit is contained in:
Paul Gofman 2025-01-29 15:27:50 -06:00
parent 7b0ae2e1d1
commit 0417c5dd8d

View File

@ -55,8 +55,10 @@ static char *get_unix_file_name( const WCHAR *path )
char *vrclient_dos_to_unix_path( const char *src )
{
WCHAR srcW[PATH_MAX] = {'\\', '?', '?', '\\', 0}, *tmp;
char buffer[4096], *dst = buffer;
uint32_t len;
char *unix_path;
uint32_t len, r;
TRACE( "src %s\n", debugstr_a(src) );
@ -65,14 +67,18 @@ char *vrclient_dos_to_unix_path( const char *src )
*dst = 0;
if (!*src) goto done;
if (IS_ABSOLUTE( src ))
len = 4;
if (!IS_ABSOLUTE( src ))
{
/* absolute path, use wine conversion */
WCHAR srcW[PATH_MAX] = {'\\', '?', '?', '\\', 0}, *tmp;
char *unix_path;
uint32_t r;
CURDIR *curdir = &NtCurrentTeb()->Peb->ProcessParameters->CurrentDirectory;
memcpy( srcW + len, curdir->DosPath.Buffer, curdir->DosPath.Length );
len += curdir->DosPath.Length / 2;
TRACE("relative, srcW %s.\n", debugstr_w(srcW));
}
r = ntdll_umbstowcs( src, strlen( src ) + 1, srcW + len, PATH_MAX - len );
r = ntdll_umbstowcs( src, strlen( src ) + 1, srcW + 4, PATH_MAX - 4 );
if (r == 0) unix_path = NULL;
else
{
@ -93,21 +99,6 @@ char *vrclient_dos_to_unix_path( const char *src )
}
free( unix_path );
}
else
{
/* relative path, just fix up backslashes */
const char *s;
char *d;
for (s = src, d = dst; *src; ++s, ++d)
{
if (*s == '\\') *d = '/';
else *d = *s;
}
*d = 0;
}
done:
len = strlen( buffer ) + 1;