]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add more code robustness check for modules under MdeModulePkg.
authorrsun3 <rsun3@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 26 Feb 2010 08:53:27 +0000 (08:53 +0000)
committerrsun3 <rsun3@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 26 Feb 2010 08:53:27 +0000 (08:53 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10108 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
MdeModulePkg/Core/Dxe/FwVol/FwVol.c
MdeModulePkg/Core/Dxe/Gcd/Gcd.c
MdeModulePkg/Core/Dxe/Hand/DriverSupport.c
MdeModulePkg/Core/Dxe/Hand/Locate.c
MdeModulePkg/Core/Dxe/Image/Image.c
MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c
MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.c

index 3a4d03bd556b844c0386f810d6abfbeea28cd162..212eed9e92ac266573ccc5921cb06186afa974fe 100644 (file)
@@ -1016,7 +1016,7 @@ CoreFwVolEventProtocolNotify (
     FvIsBeingProcesssed (FvHandle);\r
 \r
     Status = CoreHandleProtocol (FvHandle, &gEfiFirmwareVolume2ProtocolGuid, (VOID **)&Fv);\r
-    if (EFI_ERROR (Status)) {\r
+    if (EFI_ERROR (Status) || Fv == NULL) {\r
       //\r
       // FvHandle must have Firmware Volume2 protocol thus we should never get here.\r
       //\r
index f2451b03bf23c932fb4c330233ef48dda1442015..fc8d57c071495e7b9f78045b5a3be12acea215df 100644 (file)
@@ -3,7 +3,7 @@
   Layers on top of Firmware Block protocol to produce a file abstraction\r
   of FV based files.\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
+Copyright (c) 2006 - 2010, Intel Corporation. <BR>\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -565,6 +565,7 @@ NotifyFwVolBlock (
     if (EFI_ERROR (Status)) {\r
       return;\r
     }\r
+    ASSERT (FwVolHeader != NULL);\r
 \r
     if (!VerifyFvHeaderChecksum (FwVolHeader)) {\r
       CoreFreePool (FwVolHeader);\r
index 6ac093162efb7513ac449ccd088bb042b38e1b58..32a56e76604da939ac0443bb3e1fe58504c028bc 100644 (file)
@@ -3,7 +3,7 @@
   The GCD services are used to manage the memory and I/O regions that\r
   are accessible to the CPU that is executing the DXE core.\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
+Copyright (c) 2006 - 2010, Intel Corporation. <BR>\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -599,6 +599,7 @@ CoreConvertSpace (
 \r
     goto Done;\r
   }\r
+  ASSERT (StartLink != NULL && EndLink != NULL);\r
 \r
   //\r
   // Verify that the list of descriptors are unallocated non-existent memory.\r
@@ -684,6 +685,7 @@ CoreConvertSpace (
     Status = EFI_OUT_OF_RESOURCES;\r
     goto Done;\r
   }\r
+  ASSERT (TopEntry != NULL && BottomEntry != NULL);\r
 \r
   if (Operation == GCD_SET_ATTRIBUTES_MEMORY_OPERATION) {\r
     //\r
@@ -692,7 +694,7 @@ CoreConvertSpace (
     CpuArchAttributes = ConverToCpuArchAttributes (Attributes);\r
     if ( CpuArchAttributes != INVALID_CPU_ARCH_ATTRIBUTES ) {\r
       Status = CoreLocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **)&CpuArch);\r
-      if (EFI_ERROR (Status)) {\r
+      if (EFI_ERROR (Status) || CpuArch == NULL) {\r
         Status = EFI_ACCESS_DENIED;\r
         goto Done;\r
       }\r
@@ -926,6 +928,7 @@ CoreAllocateSpace (
       Status = EFI_NOT_FOUND;\r
       goto Done;\r
     }\r
+    ASSERT (StartLink != NULL && EndLink != NULL);\r
 \r
     //\r
     // Verify that the list of descriptors are unallocated memory matching GcdMemoryType.\r
@@ -1009,6 +1012,7 @@ CoreAllocateSpace (
         Status = EFI_NOT_FOUND;\r
         goto Done;\r
       }\r
+      ASSERT (StartLink != NULL && EndLink != NULL);\r
 \r
       Link = StartLink;\r
       //\r
@@ -1044,6 +1048,7 @@ CoreAllocateSpace (
     Status = EFI_OUT_OF_RESOURCES;\r
     goto Done;\r
   }\r
+  ASSERT (TopEntry != NULL && BottomEntry != NULL);\r
 \r
   //\r
   // Convert/Insert the list of descriptors from StartLink to EndLink\r
@@ -1330,6 +1335,7 @@ CoreGetMemorySpaceDescriptor (
   if (EFI_ERROR (Status)) {\r
     Status = EFI_NOT_FOUND;\r
   } else {\r
+    ASSERT (StartLink != NULL && EndLink != NULL);\r
     //\r
     // Copy the contents of the found descriptor into Descriptor\r
     //\r
@@ -1609,6 +1615,7 @@ CoreGetIoSpaceDescriptor (
   if (EFI_ERROR (Status)) {\r
     Status = EFI_NOT_FOUND;\r
   } else {\r
+    ASSERT (StartLink != NULL && EndLink != NULL);\r
     //\r
     // Copy the contents of the found descriptor into Descriptor\r
     //\r
index 71676d0ef7fa250023d8f8f7db54af2431bae229..56050a1f9fa71ffd677e73cdf7afa6ab271d0b43 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Support functions to connect/disconnect UEFI Driver model Protocol\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
+Copyright (c) 2006 - 2010, Intel Corporation. <BR>\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -766,7 +766,7 @@ CoreDisconnectController (
                &gEfiDriverBindingProtocolGuid,\r
                (VOID **)&DriverBinding\r
                );\r
-    if (EFI_ERROR (Status)) {\r
+    if (EFI_ERROR (Status) || DriverBinding == NULL) {\r
       Status = EFI_INVALID_PARAMETER;\r
       goto Done;\r
     }\r
index 5a30c5264f5ab0a6fa6b8ed5bbbdea0d18b4efe7..1a3fdbd9123f107b8f972fbca359b5b79d6c13ce 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Locate handle functions\r
 \r
-Copyright (c) 2006 - 2009, Intel Corporation. <BR>\r
+Copyright (c) 2006 - 2010, Intel Corporation. <BR>\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -200,6 +200,7 @@ CoreLocateHandle (
     return Status;\r
   }\r
 \r
+  ASSERT (GetNext != NULL);\r
   //\r
   // Enumerate out the matching handles\r
   //\r
@@ -246,6 +247,7 @@ CoreLocateHandle (
       // If this is a search by register notify and a handle was\r
       // returned, update the register notification position\r
       //\r
+      ASSERT (SearchKey != NULL);\r
       ProtNotify = SearchKey;\r
       ProtNotify->Position = ProtNotify->Position->ForwardLink;\r
     }\r
index ae4daebd9ea33d87a6e9d6ee1a458a1a1226443c..04f8368a1c2c51449b24559c863290dee28295ce 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Core image handling services to load and unload PeImage.\r
 \r
-Copyright (c) 2006 - 2009, Intel Corporation. <BR>\r
+Copyright (c) 2006 - 2010, Intel Corporation. <BR>\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -603,7 +603,7 @@ CoreLoadPeImage (
     // Locate the EBC interpreter protocol\r
     //\r
     Status = CoreLocateProtocol (&gEfiEbcProtocolGuid, NULL, (VOID **)&Image->Ebc);\r
-    if (EFI_ERROR(Status)) {\r
+    if (EFI_ERROR(Status) || Image->Ebc == NULL) {\r
       DEBUG ((DEBUG_LOAD | DEBUG_ERROR, "CoreLoadPeImage: There is no EBC interpreter for an EBC image.\n"));\r
       goto Done;\r
     }\r
@@ -1095,12 +1095,13 @@ CoreLoadImageCommon (
   // Pull out just the file portion of the DevicePath for the LoadedImage FilePath\r
   //\r
   FilePath = OriginalFilePath;\r
-  Status = CoreHandleProtocol (DeviceHandle, &gEfiDevicePathProtocolGuid, (VOID **)&HandleFilePath);\r
-  if (!EFI_ERROR (Status)) {\r
-    FilePathSize = GetDevicePathSize (HandleFilePath) - sizeof(EFI_DEVICE_PATH_PROTOCOL);\r
-    FilePath = (EFI_DEVICE_PATH_PROTOCOL *) (((UINT8 *)FilePath) + FilePathSize );\r
+  if (DeviceHandle != NULL) {\r
+    Status = CoreHandleProtocol (DeviceHandle, &gEfiDevicePathProtocolGuid, (VOID **)&HandleFilePath);\r
+    if (!EFI_ERROR (Status)) {\r
+      FilePathSize = GetDevicePathSize (HandleFilePath) - sizeof(EFI_DEVICE_PATH_PROTOCOL);\r
+      FilePath = (EFI_DEVICE_PATH_PROTOCOL *) (((UINT8 *)FilePath) + FilePathSize );\r
+    }\r
   }\r
-\r
   //\r
   // Initialize the fields for an internal driver\r
   //\r
index 2dcad4e3d527478a69e85c7d4d10cda043b8145e..d9fa20daa853aea3401a69920da77b6d1a2bafb8 100644 (file)
@@ -27,7 +27,7 @@
   3) A support protocol is not found, and the data is not available to be read\r
      without it.  This results in EFI_PROTOCOL_ERROR.\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
+Copyright (c) 2006 - 2010, Intel Corporation. <BR>\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -635,7 +635,7 @@ CreateChildNode (
       GuidedHeader = (EFI_GUID_DEFINED_SECTION *) SectionHeader;\r
       Node->EncapsulationGuid = &GuidedHeader->SectionDefinitionGuid;\r
       Status = CoreLocateProtocol (Node->EncapsulationGuid, NULL, (VOID **)&GuidedExtraction);\r
-      if (!EFI_ERROR (Status)) {\r
+      if (!EFI_ERROR (Status) && GuidedExtraction != NULL) {\r
         //\r
         // NewStreamBuffer is always allocated by ExtractSection... No caller\r
         // allocation here.\r
@@ -877,6 +877,7 @@ FindChildNode (
         if (EFI_ERROR (Status)) {\r
           return Status;\r
         }\r
+        ASSERT (CurrentChildNode != NULL);\r
       } else {\r
         ASSERT (EFI_ERROR (ErrorStatus));\r
         return ErrorStatus;\r
index 15a12d70fedc2c76f9b3c5dc748767d9757839fa..e4e6666e286aaa8f96733e344483a27837b1f270 100644 (file)
@@ -40,7 +40,7 @@
   If one of them is not satisfied, FtwWrite may fail.\r
   Usually, Spare area only takes one block. That's SpareAreaLength = BlockSize, NumberOfSpareBlock = 1.\r
 \r
-Copyright (c) 2006 - 2009, Intel Corporation                                                         \r
+Copyright (c) 2006 - 2010, Intel Corporation                                                         \r
 All rights reserved. This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -837,6 +837,7 @@ FtwGetLastWrite (
       *Complete = TRUE;\r
       return EFI_NOT_FOUND;\r
     }\r
+    ASSERT (Record != NULL);\r
   }\r
 \r
   //\r