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

[PATCH 2/4] SDV: NullCheck rule


  • To: <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Owen Smith <owen.smith@xxxxxxxxxx>
  • Date: Mon, 7 Feb 2022 13:15:01 +0000
  • Authentication-results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Owen Smith <owen.smith@xxxxxxxxxx>
  • Delivery-date: Mon, 07 Feb 2022 13:15:15 +0000
  • Ironport-data: A9a23:6NFfN6qpzYZlf/INKjAVKiX3qudeBmI4YhIvgKrLsJaIsI4StFCzt garIBnXPP+MYWX0Ktsgbtyw/UIOuMLdydMyHFc5qXw2Fn5E+JuZCYyVIHmrMnLJJKUvbq7GA +byyDXkBJppJpMJjk71atANlZT4vE2xbuKU5NTsY0idfic5Dndx4f5fs7Rh2NQw24DmW1rlV e7a+KUzBnf0g1aYDUpMg06zgEsHUCPa4W5wUvQWPJinjXeG/5UnJMt3yZKZdhMUdrJ8DO+iL 9sv+Znilo/vE7XBPfv++lrzWhVirrc/pmFigFIOM0SpqkAqSiDfTs/XnRfTAKtao2zhojx/9 DlCncSARCpwA6qUpO8cCV5DUC5TZ7RK07CSdBBTseTLp6HHW37lwvEoB0AqJ4wIvO1wBAmi9 9RBdmpLNErawbvrnvTrEYGAhex6RCXvFIQAt3cm1jTYEfYOSpHfWaTao9Rf2V/cg+gQQa6CO JNBNFKDajzCOzBMHAZMLas1kdeBpEHzWSVGrXGa8P9fD2/7k1UqjemF3MDuUsOLQ4BNgAOUq 3zL+0z9AwoGL5qPxDyd6HWui+TT2yThV+ov+KaQr6AwxgfJnypKVUNQBQDTTeSFZlCWA+JSB hUp/XISpqlos1foQfSnRhGTryvR1vIDYOZ4H+o/4QCL76Pb5QeFG2QJJgJ8hMwaWNweHmJzi ALQ9z/9LXk26eDOFyrBnluBhW7qYUAowXk+iTjopOfvy/3qu8kNgx3GVb6P+4bl34SuSVkcL 91nxRXSZon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Im4YwfR7dT/zqB5FKvLt6O IRW3KrIWS4n2rNGaEdzzHdXtoFBZHx5LJn3q4ciTm1OGDsO6aUB7KxSvqH6cQkx6oAT9LIv+XI zxbgpXuo7g+YGr27vFRBcAfGAObgPaalUGEuxIjkr6YAvZ0DVXL7eqUFc//2k0E0vRy2F06MAH 4NZkvzg6Dm21zxuskV8Kf/v0
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

Check memory allocation succeeds.
Also check RtlUnicodeStringToAnsiString succeeds, though this failure is
unlikely when the buffer is pre-allocated.

Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
---
 src/common/registry.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/common/registry.c b/src/common/registry.c
index 9f5628c..b9b56e1 100644
--- a/src/common/registry.c
+++ b/src/common/registry.c
@@ -641,8 +641,15 @@ RegistryEnumerateValues(
         Ansi.MaximumLength = (USHORT)((Basic->NameLength / sizeof (WCHAR)) + 
sizeof (CHAR));
         Ansi.Buffer = __RegistryAllocate(Ansi.MaximumLength);
 
+        status = STATUS_NO_MEMORY;
+        if (Ansi.Buffer == NULL)
+            goto fail6;
+
         status = RtlUnicodeStringToAnsiString(&Ansi, &Unicode, FALSE);
-        ASSERT(NT_SUCCESS(status));
+        if (!NT_SUCCESS(status)) {
+            __RegistryFree(Ansi.Buffer);
+            goto fail7;
+        }
 
         Ansi.Length = (USHORT)(strlen(Ansi.Buffer) * sizeof (CHAR));        
 
@@ -651,7 +658,7 @@ RegistryEnumerateValues(
         __RegistryFree(Ansi.Buffer);
 
         if (!NT_SUCCESS(status))
-            goto fail6;
+            goto fail8;
     }
 
     __RegistryFree(Basic);
@@ -660,6 +667,8 @@ RegistryEnumerateValues(
 
     return STATUS_SUCCESS;
 
+fail8:
+fail7:
 fail6:
 fail5:
     __RegistryFree(Basic);
-- 
2.33.0.windows.2




 


Rackspace

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