Author: tfaber
Date: Sun Nov 24 20:04:45 2013
New Revision: 61093

URL: http://svn.reactos.org/svn/reactos?rev=61093&view=rev
Log:
[RTL]
- Allow parsing manifest files larger than 32 kB. Fix a DPRINT. Patch by David 
Quintana.
CORE-7642 #resolve

Modified:
    trunk/reactos/lib/rtl/actctx.c

Modified: trunk/reactos/lib/rtl/actctx.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/actctx.c?rev=61093&r1=61092&r2=61093&view=diff
==============================================================================
--- trunk/reactos/lib/rtl/actctx.c      [iso-8859-1] (original)
+++ trunk/reactos/lib/rtl/actctx.c      [iso-8859-1] Sun Nov 24 20:04:45 2013
@@ -1176,6 +1176,7 @@
                                                          struct assembly* 
assembly)
 {
     xmlstr_t            attr_name, attr_value;
+    UNICODE_STRING      attr_nameU, attr_valueU;
     BOOL                end = FALSE, error;
     struct entity*      entity;
 
@@ -1194,7 +1195,9 @@
         }
         else
         {
-            DPRINT1("unknown attr %S=%S\n", attr_name.ptr, attr_value.ptr);
+            attr_nameU = xmlstr2unicode(&attr_name);
+            attr_valueU = xmlstr2unicode(&attr_value);
+            DPRINT1("unknown attr %wZ=%wZ\n", &attr_nameU, &attr_valueU);
         }
     }
 
@@ -1658,36 +1661,31 @@
     else
     {
         /* TODO: this doesn't handle arbitrary encodings */
-        ANSI_STRING xmlA;
-        UNICODE_STRING xmlW;
-
-        ASSERT(size < MAXUSHORT);
-        xmlA.Buffer = (PCHAR)buffer;
-        xmlA.Length = xmlA.MaximumLength = (USHORT)size;
-
-        _SEH2_TRY
-        {
-            status = RtlAnsiStringToUnicodeString(&xmlW, &xmlA, TRUE);
-        }
-        _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
-        {
-            DPRINT1("Exception accessing buffer\n");
-            _SEH2_YIELD(return STATUS_SXS_CANT_GEN_ACTCTX);
-        }
-        _SEH2_END;
-
+        WCHAR *new_buff;
+        ULONG sizeU;
+
+        status = RtlMultiByteToUnicodeSize(&sizeU, buffer, size);
         if (!NT_SUCCESS(status))
         {
-            DPRINT1("RtlAnsiStringToUnicodeString failed with %lx\n", status);
+            DPRINT1("RtlMultiByteToUnicodeSize failed with %lx\n", status);
             return STATUS_SXS_CANT_GEN_ACTCTX;
         }
-        ASSERT(xmlW.Buffer != NULL);
-
-        xmlbuf.ptr = xmlW.Buffer;
-        xmlbuf.end = xmlbuf.ptr + xmlW.Length / sizeof(WCHAR);
-        status = parse_manifest_buffer( acl, assembly, ai, &xmlbuf );
-
-        RtlFreeUnicodeString(&xmlW);
+
+        new_buff = RtlAllocateHeap(RtlGetProcessHeap(), 0, sizeU);
+        if (!new_buff)
+            return STATUS_NO_MEMORY;
+
+        status = RtlMultiByteToUnicodeN(new_buff, sizeU, &sizeU, buffer, size);
+        if (!NT_SUCCESS(status))
+        {
+            DPRINT1("RtlMultiByteToUnicodeN failed with %lx\n", status);
+            return STATUS_SXS_CANT_GEN_ACTCTX;
+        }
+
+        xmlbuf.ptr = new_buff;
+        xmlbuf.end = xmlbuf.ptr + sizeU / sizeof(WCHAR);
+        status = parse_manifest_buffer(acl, assembly, ai, &xmlbuf);
+        RtlFreeHeap(RtlGetProcessHeap(), 0, new_buff);
     }
     return status;
 }


Reply via email to