ntdll: Disallow relative paths in wine_unix_to_nt_file_name(), handle them in the caller.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
3aa4feb578
commit
49fcd632e4
|
@ -301,10 +301,24 @@ WCHAR * CDECL wine_get_dos_file_name( LPCSTR str )
|
||||||
{
|
{
|
||||||
UNICODE_STRING nt_name;
|
UNICODE_STRING nt_name;
|
||||||
ANSI_STRING unix_name;
|
ANSI_STRING unix_name;
|
||||||
|
NTSTATUS status;
|
||||||
|
WCHAR *buffer;
|
||||||
DWORD len;
|
DWORD len;
|
||||||
|
|
||||||
RtlInitAnsiString( &unix_name, str );
|
if (str[0] != '/') /* relative path name */
|
||||||
if (!set_ntstatus( wine_unix_to_nt_file_name( &unix_name, &nt_name ))) return NULL;
|
{
|
||||||
|
len = strlen( str ) + 1;
|
||||||
|
if (!(buffer = RtlAllocateHeap( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) return NULL;
|
||||||
|
MultiByteToWideChar( CP_UNIXCP, 0, str, len, buffer, len );
|
||||||
|
status = RtlDosPathNameToNtPathName_U_WithStatus( buffer, &nt_name, NULL, NULL );
|
||||||
|
RtlFreeHeap( GetProcessHeap(), 0, buffer );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RtlInitAnsiString( &unix_name, str );
|
||||||
|
status = wine_unix_to_nt_file_name( &unix_name, &nt_name );
|
||||||
|
}
|
||||||
|
if (!set_ntstatus( status )) return NULL;
|
||||||
if (nt_name.Buffer[5] == ':')
|
if (nt_name.Buffer[5] == ':')
|
||||||
{
|
{
|
||||||
/* get rid of the \??\ prefix */
|
/* get rid of the \??\ prefix */
|
||||||
|
|
|
@ -891,23 +891,10 @@ NTSTATUS WINAPI RtlSetCurrentDirectory_U(const UNICODE_STRING* dir)
|
||||||
*/
|
*/
|
||||||
NTSTATUS CDECL wine_unix_to_nt_file_name( const ANSI_STRING *name, UNICODE_STRING *nt )
|
NTSTATUS CDECL wine_unix_to_nt_file_name( const ANSI_STRING *name, UNICODE_STRING *nt )
|
||||||
{
|
{
|
||||||
unsigned int lenW, lenA = name->Length;
|
unsigned int lenA = name->Length;
|
||||||
const char *path = name->Buffer;
|
const char *path = name->Buffer;
|
||||||
|
|
||||||
if (!lenA) return STATUS_INVALID_PARAMETER;
|
if (!lenA) return STATUS_INVALID_PARAMETER;
|
||||||
|
if (path[0] != '/') return STATUS_INVALID_PARAMETER; /* relative path not supported */
|
||||||
if (path[0] != '/') /* relative path name */
|
|
||||||
{
|
|
||||||
WCHAR *tmp;
|
|
||||||
NTSTATUS status;
|
|
||||||
|
|
||||||
if (!(tmp = RtlAllocateHeap( GetProcessHeap(), 0, (lenA + 1) * sizeof(WCHAR) )))
|
|
||||||
return STATUS_NO_MEMORY;
|
|
||||||
lenW = ntdll_umbstowcs( path, lenA, tmp, lenA );
|
|
||||||
tmp[lenW] = 0;
|
|
||||||
status = RtlDosPathNameToNtPathName_U_WithStatus( tmp, nt, NULL, NULL );
|
|
||||||
RtlFreeHeap( GetProcessHeap(), 0, tmp );
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
return unix_funcs->unix_to_nt_file_name( name, nt );
|
return unix_funcs->unix_to_nt_file_name( name, nt );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue