From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.151; helo=mga17.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (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 D73ED22393624 for ; Fri, 2 Feb 2018 00:18:15 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Feb 2018 00:23:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,447,1511856000"; d="scan'208";a="24154934" Received: from shwdeopenpsi168.ccr.corp.intel.com ([10.239.158.129]) by orsmga003.jf.intel.com with ESMTP; 02 Feb 2018 00:23:52 -0800 From: Yonghong Zhu To: edk2-devel@lists.01.org Date: Fri, 2 Feb 2018 16:23:50 +0800 Message-Id: <1517559830-2432-1-git-send-email-yonghong.zhu@intel.com> X-Mailer: git-send-email 2.6.1.windows.1 Subject: [Patch] BaseTools: enhance error check for DatumType format X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Feb 2018 08:18:16 -0000 Add a check for DatumType format, eg: VOID *, original Tool will crash but no detail error message which cause confusion to user. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu --- BaseTools/Source/Python/Workspace/DecBuildData.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py b/BaseTools/Source/Python/Workspace/DecBuildData.py index 2fd3820..2266b0b 100644 --- a/BaseTools/Source/Python/Workspace/DecBuildData.py +++ b/BaseTools/Source/Python/Workspace/DecBuildData.py @@ -1,9 +1,9 @@ ## @file # This file is used to create a database used by build tool # -# Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2008 - 2018, 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 # http://opensource.org/licenses/bsd-license.php @@ -421,10 +421,15 @@ class DecBuildData(PackageBuildClassObject): Setting,LineNo = PcdDict[self._Arch, PcdCName, TokenSpaceGuid] if Setting == None: continue DefaultValue, DatumType, TokenNumber = AnalyzePcdData(Setting) + if DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]: + StructPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_]*$') + if StructPattern.match(DatumType) == None: + EdkLogger.error('build', FORMAT_INVALID, "DatumType only support BOOLEAN, UINT8, UINT16, UINT32, UINT64, VOID* or a valid struct name.", File=self.MetaFile, Line=LineNo) + validateranges, validlists, expressions = self._RawData.GetValidExpression(TokenSpaceGuid, PcdCName) PcdObj = PcdClassObject( PcdCName, TokenSpaceGuid, self._PCD_TYPE_STRING_[Type], -- 2.6.1.windows.1