summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MdeModulePkg/Universal/PCD/Dxe/Service.c8
-rw-r--r--MdeModulePkg/Universal/PCD/Pei/Service.c10
2 files changed, 13 insertions, 5 deletions
diff --git a/MdeModulePkg/Universal/PCD/Dxe/Service.c b/MdeModulePkg/Universal/PCD/Dxe/Service.c
index 8a550d38e0..bf8e74dfb3 100644
--- a/MdeModulePkg/Universal/PCD/Dxe/Service.c
+++ b/MdeModulePkg/Universal/PCD/Dxe/Service.c
@@ -1,7 +1,7 @@
/** @file
Help functions used by PCD DXE driver.
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -741,7 +741,11 @@ SetWorker (
ASSERT (TokenNumber + 1 < PCD_TOTAL_TOKEN_NUMBER + 1);
if (PtrType) {
- if (*Size > DxePcdGetSize (TokenNumber + 1)) {
+ //
+ // Get MaxSize first, then check new size with max buffer size.
+ //
+ GetPtrTypeSize (TokenNumber, &MaxSize);
+ if (*Size > MaxSize) {
return EFI_INVALID_PARAMETER;
}
} else {
diff --git a/MdeModulePkg/Universal/PCD/Pei/Service.c b/MdeModulePkg/Universal/PCD/Pei/Service.c
index 7ed4117a58..6b5dec3996 100644
--- a/MdeModulePkg/Universal/PCD/Pei/Service.c
+++ b/MdeModulePkg/Universal/PCD/Pei/Service.c
@@ -2,7 +2,7 @@
The driver internal functions are implmented here.
They build Pei PCD database, and provide access service to PCD database.
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -386,7 +386,11 @@ SetWorker (
LocalTokenNumber = PeiPcdDb->Init.LocalTokenNumberTable[TokenNumber];
if (PtrType) {
- if (*Size > PeiPcdGetSize (TokenNumber + 1)) {
+ //
+ // Get MaxSize first, then check new size with max buffer size.
+ //
+ GetPtrTypeSize (TokenNumber, &MaxSize, PeiPcdDb);
+ if (*Size > MaxSize) {
return EFI_INVALID_PARAMETER;
}
} else {
@@ -406,7 +410,7 @@ SetWorker (
if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == PCD_TYPE_SKU_ENABLED) {
if (PtrType) {
- MaxSize = GetPtrTypeSize (TokenNumber, &MaxSize, PeiPcdDb);
+ GetPtrTypeSize (TokenNumber, &MaxSize, PeiPcdDb);
} else {
MaxSize = *Size;
}