mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 22:55:41 +00:00
[RTL]
- Use RtlAnsiStringToUnicodeString instead of mbstowcs to correctly handle manifests that aren't null-terminated See issue #6743 for more details. svn path=/trunk/; revision=56649
This commit is contained in:
parent
c43df67bd6
commit
25d5ac32b6
1 changed files with 14 additions and 15 deletions
|
@ -1576,13 +1576,17 @@ static NTSTATUS parse_manifest( struct actctx_loader* acl, struct assembly_ident
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* let's assume utf-8 for now */
|
/* TODO: this doesn't handle arbitrary encodings */
|
||||||
size_t len;
|
ANSI_STRING xmlA;
|
||||||
WCHAR *new_buff;
|
UNICODE_STRING xmlW;
|
||||||
|
|
||||||
|
ASSERT(size < MAXUSHORT);
|
||||||
|
xmlA.Buffer = (PCHAR)buffer;
|
||||||
|
xmlA.Length = xmlA.MaximumLength = (USHORT)size;
|
||||||
|
|
||||||
_SEH2_TRY
|
_SEH2_TRY
|
||||||
{
|
{
|
||||||
len = mbstowcs(NULL, buffer, size);
|
status = RtlAnsiStringToUnicodeString(&xmlW, &xmlA, TRUE);
|
||||||
}
|
}
|
||||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||||
{
|
{
|
||||||
|
@ -1591,23 +1595,18 @@ static NTSTATUS parse_manifest( struct actctx_loader* acl, struct assembly_ident
|
||||||
}
|
}
|
||||||
_SEH2_END;
|
_SEH2_END;
|
||||||
|
|
||||||
DPRINT("len = %x\n", len);
|
if (!NT_SUCCESS(status))
|
||||||
|
|
||||||
if (len == -1)
|
|
||||||
{
|
{
|
||||||
DPRINT1( "utf-8 conversion failed\n" );
|
DPRINT1("RtlAnsiStringToUnicodeString failed with %lx\n", status);
|
||||||
return STATUS_SXS_CANT_GEN_ACTCTX;
|
return STATUS_SXS_CANT_GEN_ACTCTX;
|
||||||
}
|
}
|
||||||
if (!(new_buff = RtlAllocateHeap( RtlGetProcessHeap(), HEAP_ZERO_MEMORY, len)))
|
ASSERT(xmlW.Buffer != NULL);
|
||||||
return STATUS_NO_MEMORY;
|
|
||||||
|
|
||||||
mbstowcs( new_buff, buffer, size);
|
xmlbuf.ptr = xmlW.Buffer;
|
||||||
xmlbuf.ptr = new_buff;
|
xmlbuf.end = xmlbuf.ptr + xmlW.Length / sizeof(WCHAR);
|
||||||
|
|
||||||
xmlbuf.end = xmlbuf.ptr + len / sizeof(WCHAR);
|
|
||||||
status = parse_manifest_buffer( acl, assembly, ai, &xmlbuf );
|
status = parse_manifest_buffer( acl, assembly, ai, &xmlbuf );
|
||||||
|
|
||||||
RtlFreeHeap( RtlGetProcessHeap(), 0, new_buff );
|
RtlFreeUnicodeString(&xmlW);
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue