Light-weight Memory Management Routines for OpenSSL-based Crypto\r
Library at Runtime Phase.\r
\r
-Copyright (c) 2009 - 2017, 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
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
-#include <OpenSslSupport.h>\r
+#include <CrtLibSupport.h>\r
#include <Library/UefiBootServicesTableLib.h>\r
#include <Library/UefiRuntimeLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
#include <Guid/EventGroup.h>\r
\r
//----------------------------------------------------------------\r
\r
StartPageIndex = RT_SIZE_TO_PAGES (mRTPageTable->LastEmptyPageOffset);\r
ReqPages = RT_SIZE_TO_PAGES (AllocationSize);\r
+ if (ReqPages > mRTPageTable->PageCount) {\r
+ //\r
+ // No enough region for object allocation.\r
+ //\r
+ return (UINTN)(-1);\r
+ }\r
\r
//\r
// Look up the free memory region with in current memory map table.\r
// Look up the free memory region from the beginning of the memory table\r
// until the StartCursorOffset\r
//\r
+ if (ReqPages > StartPageIndex) {\r
+ //\r
+ // No enough region for object allocation.\r
+ //\r
+ return (UINTN)(-1);\r
+ }\r
for (Index = 0; Index < (StartPageIndex - ReqPages); ) {\r
//\r
// Check Consecutive ReqPages Pages.\r