]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/PeiHobLib/HobLib.c
Update HobLib and Hob Service to avoid data over flow.
[mirror_edk2.git] / MdePkg / Library / PeiHobLib / HobLib.c
index 113de832fc488577278732c51eff31a3da12791e..0586ba86c0b4b9755b8dd4a238fb65854a3eff94 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Provide Hob Library functions for Pei phase.\r
 \r
-Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 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
@@ -349,7 +349,8 @@ BuildResourceDescriptorHob (
   \r
   If Guid is NULL, then ASSERT().\r
   If there is no additional space for HOB creation, then ASSERT().\r
-  If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().\r
+  If DataLength > (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().\r
+  HobLength is UINT16 and multiples of 8 bytes, so the max HobLength is 0xFFF8.\r
 \r
   @param  Guid          The GUID to tag the customized HOB.\r
   @param  DataLength    The size of the data payload for the GUID HOB.\r
@@ -375,7 +376,7 @@ BuildGuidHob (
   //\r
   // Make sure that data length is not too long.\r
   //\r
-  ASSERT (DataLength <= (0xffff - sizeof (EFI_HOB_GUID_TYPE)));\r
+  ASSERT (DataLength <= (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE)));\r
 \r
   Hob = InternalPeiCreateHob (EFI_HOB_TYPE_GUID_EXTENSION, (UINT16) (sizeof (EFI_HOB_GUID_TYPE) + DataLength));\r
   if (Hob == NULL) {\r
@@ -399,7 +400,8 @@ BuildGuidHob (
   If Guid is NULL, then ASSERT().\r
   If Data is NULL and DataLength > 0, then ASSERT().\r
   If there is no additional space for HOB creation, then ASSERT().\r
-  If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().\r
+  If DataLength > (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().\r
+  HobLength is UINT16 and multiples of 8 bytes, so the max HobLength is 0xFFF8.\r
 \r
   @param  Guid          The GUID to tag the customized HOB.\r
   @param  Data          The data to be copied into the data field of the GUID HOB.\r