]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix PcdSetPtr() service to use the max buffer size to check whether new buffer data...
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 28 Nov 2011 03:36:25 +0000 (03:36 +0000)
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 28 Nov 2011 03:36:25 +0000 (03:36 +0000)
Signed-off-by: lgao4
Reviewed-by: jlin16
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12789 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/PCD/Dxe/Service.c
MdeModulePkg/Universal/PCD/Pei/Service.c

index 8a550d38e03e532e92c82a2853284299ec848a87..bf8e74dfb328e79be067ad29c7b022f13f893c62 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
     Help functions used by PCD DXE driver.\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
@@ -741,7 +741,11 @@ SetWorker (
   ASSERT (TokenNumber + 1 < PCD_TOTAL_TOKEN_NUMBER + 1);\r
 \r
   if (PtrType) {\r
-    if (*Size > DxePcdGetSize (TokenNumber + 1)) {\r
+    //\r
+    // Get MaxSize first, then check new size with max buffer size.\r
+    //\r
+    GetPtrTypeSize (TokenNumber, &MaxSize);\r
+    if (*Size > MaxSize) {\r
       return EFI_INVALID_PARAMETER;\r
     }\r
   } else {\r
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