Commit 9e8db5a2 authored by Alexandre Julliard's avatar Alexandre Julliard

kernel32: Fix assumptions about 0-size output buffer in ntdll Unicode conversion functions.

parent 94d2b474
......@@ -273,10 +273,25 @@ DWORD FILE_name_WtoA( LPCWSTR src, INT srclen, LPSTR dest, INT destlen )
DWORD ret;
if (srclen < 0) srclen = strlenW( src ) + 1;
if (!AreFileApisANSI())
RtlUnicodeToOemN( dest, destlen, &ret, src, srclen * sizeof(WCHAR) );
if (!destlen)
{
if (!AreFileApisANSI())
{
UNICODE_STRING strW;
strW.Buffer = (WCHAR *)src;
strW.Length = srclen * sizeof(WCHAR);
ret = RtlUnicodeStringToOemSize( &strW ) - 1;
}
else
RtlUnicodeToMultiByteSize( &ret, src, srclen * sizeof(WCHAR) );
}
else
RtlUnicodeToMultiByteN( dest, destlen, &ret, src, srclen * sizeof(WCHAR) );
{
if (!AreFileApisANSI())
RtlUnicodeToOemN( dest, destlen, &ret, src, srclen * sizeof(WCHAR) );
else
RtlUnicodeToMultiByteN( dest, destlen, &ret, src, srclen * sizeof(WCHAR) );
}
return ret;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment