]> xenbits.xensource.com Git - people/pauldu/xenbus.git/commitdiff
Fix a couple of issues picked up by Windows 10 verifier
authorPaul Durrant <paul.durrant@citrix.com>
Wed, 21 Sep 2016 12:49:20 +0000 (13:49 +0100)
committerPaul Durrant <paul.durrant@citrix.com>
Wed, 21 Sep 2016 12:49:20 +0000 (13:49 +0100)
- It's possible for MmAllocatePagesForMdlEx() not to satisfy the
  full allocation request, but not fail. Thus AllocatePage() should
  check that the completed allocation actually matches what it
  asks for.

- RegistryCreateKey() has a memory leak.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
src/common/registry.c
src/common/util.h

index 233569fddd8affc3ad350301a6022c04b34155d6..fb05691134b4e19927def53c18ef7076bfcd0c93 100644 (file)
@@ -232,6 +232,8 @@ RegistryCreateKey(
 
     *Key = Child;
 
+    __RegistryFree(Buffer);
+
     return STATUS_SUCCESS;
 
 fail4:
index dc8a60eee13cf29728ae7f72a6a17ee7f4377906..92a3b19843709d7ccb0419a8e891f945bc8d9a05 100644 (file)
@@ -190,12 +190,15 @@ __AllocatePage(
                                   SkipBytes,
                                   TotalBytes,
                                   MmCached,
-                                  0);
+                                  MM_DONT_ZERO_ALLOCATION);
 
     status = STATUS_NO_MEMORY;
     if (Mdl == NULL)
         goto fail1;
 
+    if (Mdl->ByteCount < PAGE_SIZE)
+        goto fail2;
+
     ASSERT((Mdl->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA |
                              MDL_PARTIAL_HAS_BEEN_MAPPED |
                              MDL_PARTIAL |
@@ -212,7 +215,7 @@ __AllocatePage(
 
     status = STATUS_UNSUCCESSFUL;
     if (MdlMappedSystemVa == NULL)
-        goto fail2;
+        goto fail3;
 
     ASSERT3P(MdlMappedSystemVa, ==, Mdl->MappedSystemVa);
 
@@ -220,6 +223,9 @@ __AllocatePage(
 
     return Mdl;
 
+fail3:
+    Error("fail3\n");
+
 fail2:
     Error("fail2\n");