]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Update HobLib and Hob Service to avoid data over flow.
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 17 Jul 2012 01:51:26 +0000 (01:51 +0000)
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 17 Jul 2012 01:51:26 +0000 (01:51 +0000)
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Rui Sun <rui.sun@intel.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13533 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Core/Pei/Hob/Hob.c
MdeModulePkg/Core/Pei/Memory/MemoryServices.c

index 682fa781cdcb17c7ce0420cc322b205736ce9d2c..e0ee8e7f10621cbaccec0f3a0afbcb5f7bca8f36 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   This module provide Hand-Off Block manupulation.\r
   \r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
 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
@@ -89,6 +89,12 @@ PeiCreateHob (
 \r
   HandOffHob = *Hob;\r
 \r
+  //\r
+  // Check Length to avoid data overflow. \r
+  //\r
+  if (0x10000 - Length <= 0x7) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
   Length     = (UINT16)((Length + 0x7) & (~0x7));\r
 \r
   FreeMemory = HandOffHob->EfiFreeMemoryTop -\r
index ded8754e857dc833f4668b0b071333b3bc698c8d..c7a06a3c5275322cbf6a8cd74079495f547af3f8 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   EFI PEI Core memory services\r
   \r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
 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
@@ -249,9 +249,9 @@ PeiAllocatePool (
   \r
   //\r
   // Generally, the size of heap in temporary memory does not exceed to 64K,\r
-  // so the maxmium size of pool is 0x10000 - sizeof (EFI_HOB_MEMORY_POOL)\r
+  // HobLength is multiples of 8 bytes, so the maxmium size of pool is 0xFFF8 - sizeof (EFI_HOB_MEMORY_POOL)\r
   //\r
-  if (Size >= (0x10000 - sizeof (EFI_HOB_MEMORY_POOL))) {\r
+  if (Size > (0xFFF8 - sizeof (EFI_HOB_MEMORY_POOL))) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
   \r