[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[XENBUS PATCH 07/13] registry: Suppress uninitialized memory warnings



The registry functions will fail if the initial ZwQueryKey unexpectedly
succeeds.

While this may not happen in practice, do so to avoid having to suppress
compiler warnings.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>
---
 src/common/registry.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/src/common/registry.c b/src/common/registry.c
index 73581a3..7965233 100644
--- a/src/common/registry.c
+++ b/src/common/registry.c
@@ -386,11 +386,11 @@ RegistryOpenHardwareKey(
                         NULL,
                         0,
                         &Length);
-    if (status != STATUS_BUFFER_OVERFLOW &&
+    if (!NT_SUCCESS(status) &&
+        status != STATUS_BUFFER_OVERFLOW &&
         status != STATUS_BUFFER_TOO_SMALL)
         goto fail2;
 
-#pragma prefast(suppress:6102)
     Info = __RegistryAllocate(Length + sizeof (WCHAR));
 
     status = STATUS_NO_MEMORY;
@@ -565,7 +565,6 @@ RegistryEnumerateSubKeys(
         status != STATUS_BUFFER_TOO_SMALL)
         goto fail1;
 
-#pragma prefast(suppress:6102)
     Full = __RegistryAllocate(Size);
 
     status = STATUS_NO_MEMORY;
@@ -669,7 +668,6 @@ RegistryEnumerateValues(
         status != STATUS_BUFFER_TOO_SMALL)
         goto fail1;
 
-#pragma prefast(suppress:6102)
     Full = __RegistryAllocate(Size);
 
     status = STATUS_NO_MEMORY;
@@ -810,11 +808,11 @@ RegistryQueryDwordValue(
                              NULL,
                              0,
                              &Size);
-    if (status != STATUS_BUFFER_OVERFLOW &&
+    if (!NT_SUCCESS(status) &&
+        status != STATUS_BUFFER_OVERFLOW &&
         status != STATUS_BUFFER_TOO_SMALL)
         goto fail2;
 
-#pragma prefast(suppress:6102)
     Partial = __RegistryAllocate(Size);
 
     status = STATUS_NO_MEMORY;
@@ -1038,11 +1036,11 @@ RegistryQuerySzValue(
                              NULL,
                              0,
                              &Size);
-    if (status != STATUS_BUFFER_OVERFLOW &&
+    if (!NT_SUCCESS(status) &&
+        status != STATUS_BUFFER_OVERFLOW &&
         status != STATUS_BUFFER_TOO_SMALL)
         goto fail2;
 
-#pragma prefast(suppress:6102)
     Value = __RegistryAllocate(Size);
 
     status = STATUS_NO_MEMORY;
@@ -1125,11 +1123,11 @@ RegistryQueryBinaryValue(
                              NULL,
                              0,
                              &Size);
-    if (status != STATUS_BUFFER_OVERFLOW &&
+    if (!NT_SUCCESS(status) &&
+        status != STATUS_BUFFER_OVERFLOW &&
         status != STATUS_BUFFER_TOO_SMALL)
         goto fail2;
 
-#pragma prefast(suppress:6102)
     Partial = __RegistryAllocate(Size);
 
     status = STATUS_NO_MEMORY;
@@ -1256,12 +1254,12 @@ RegistryQueryKeyName(
                         NULL,
                         0,
                         &Size);
-    if (status != STATUS_BUFFER_OVERFLOW &&
+    if (!NT_SUCCESS(status) &&
+        status != STATUS_BUFFER_OVERFLOW &&
         status != STATUS_BUFFER_TOO_SMALL)
         goto fail1;
 
     // Name information is not intrinsically NULL terminated
-#pragma prefast(suppress:6102)
     Value = __RegistryAllocate(Size + sizeof (WCHAR));
 
     status = STATUS_NO_MEMORY;
-- 
2.50.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.