/** @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
\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
/** @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
\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