From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from g2t2355.austin.hpe.com (g2t2355.austin.hpe.com [15.233.44.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id CA0E981D33 for ; Tue, 1 Nov 2016 19:40:40 -0700 (PDT) Received: from SHIAC15.asiapacific.hpqcorp.net (unknown [16.169.149.242]) by g2t2355.austin.hpe.com (Postfix) with ESMTP id A721C4C; Wed, 2 Nov 2016 02:40:39 +0000 (UTC) From: Cinnamon Shia To: edk2-devel@lists.01.org Cc: feng.tian@intel.com, star.zeng@intel.com, Cinnamon Shia Date: Wed, 2 Nov 2016 10:40:34 +0800 Message-Id: <20161102024034.260-1-cinnamon.shia@hpe.com> X-Mailer: git-send-email 2.10.0.windows.1 Subject: [PATCH] MdeModulePkg/PCD: Fix PcdGetNextToken may get a wrong PCD token X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 02:40:40 -0000 If there are two DynamicEx PCDs have the same PCD token number but in different PCD token spaces, the PcdGetNextToken function may get the wrong PCD token. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Cinnamon Shia --- MdeModulePkg/Universal/PCD/Dxe/Service.c | 3 ++- MdeModulePkg/Universal/PCD/Pei/Pcd.c | 21 +++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/MdeModulePkg/Universal/PCD/Dxe/Service.c b/MdeModulePkg/Universal/PCD/Dxe/Service.c index 6d0b0f8..bf77130 100644 --- a/MdeModulePkg/Universal/PCD/Dxe/Service.c +++ b/MdeModulePkg/Universal/PCD/Dxe/Service.c @@ -3,6 +3,7 @@ Copyright (c) 2014, Hewlett-Packard Development Company, L.P.
Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP
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 @@ -715,7 +716,7 @@ ExGetNextTokeNumber ( } for ( ; Index < ExMapTableCount; Index++) { - if (ExMapTable[Index].ExTokenNumber == *TokenNumber) { + if ((ExMapTable[Index].ExTokenNumber == *TokenNumber) && (ExMapTable[Index].ExGuidIndex == GuidTableIdx)) { break; } } diff --git a/MdeModulePkg/Universal/PCD/Pei/Pcd.c b/MdeModulePkg/Universal/PCD/Pei/Pcd.c index 7a486b7..668860b 100644 --- a/MdeModulePkg/Universal/PCD/Pei/Pcd.c +++ b/MdeModulePkg/Universal/PCD/Pei/Pcd.c @@ -2,13 +2,14 @@ All Pcd Ppi services are implemented here. Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
-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 -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +(C) Copyright 2016 Hewlett Packard Enterprise Development LP
+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 +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ @@ -1116,13 +1117,17 @@ PeiPcdGetNextToken ( } if (Found) { + // + // If given token number is PCD_INVALID_TOKEN_NUMBER, then return the first + // token number in found token space. + // if (*TokenNumber == PCD_INVALID_TOKEN_NUMBER) { *TokenNumber = ExMapTable[Index].ExTokenNumber; return EFI_SUCCESS; } for ( ; Index < PeiPcdDb->ExTokenCount; Index++) { - if (ExMapTable[Index].ExTokenNumber == *TokenNumber) { + if ((ExMapTable[Index].ExTokenNumber == *TokenNumber) && (ExMapTable[Index].ExGuidIndex == GuidTableIdx)) { break; } } -- 2.10.0.windows.1