]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/PCD/Pei/Service.c
Fix PcdSetPtr() service to use the max buffer size to check whether new buffer data...
[mirror_edk2.git] / MdeModulePkg / Universal / PCD / Pei / Service.c
index 7ed4117a58075cbcbfa2ec39f10c692313cccbf6..6b5dec399622658941cf689d26db71b5b2270985 100644 (file)
@@ -2,7 +2,7 @@
   The driver internal functions are implmented here.\r
   They build Pei PCD database, and provide access service to PCD database.\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2011, 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
@@ -386,7 +386,11 @@ SetWorker (
   LocalTokenNumber = PeiPcdDb->Init.LocalTokenNumberTable[TokenNumber];\r
 \r
   if (PtrType) {\r
-    if (*Size > PeiPcdGetSize (TokenNumber + 1)) {\r
+    //\r
+    // Get MaxSize first, then check new size with max buffer size.\r
+    //\r
+    GetPtrTypeSize (TokenNumber, &MaxSize, PeiPcdDb);\r
+    if (*Size > MaxSize) {\r
       return EFI_INVALID_PARAMETER;\r
     }\r
   } else {\r
@@ -406,7 +410,7 @@ SetWorker (
 \r
   if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == PCD_TYPE_SKU_ENABLED) {\r
     if (PtrType) {\r
-      MaxSize = GetPtrTypeSize (TokenNumber, &MaxSize, PeiPcdDb);\r
+      GetPtrTypeSize (TokenNumber, &MaxSize, PeiPcdDb);\r
     } else {\r
       MaxSize = *Size;\r
     }\r