From: Yonghong Zhu Date: Mon, 22 Jan 2018 05:46:52 +0000 (+0800) Subject: BaseTools: Add DefaultStore section format Check X-Git-Tag: edk2-stable201903~2553 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=767ddbe87416afe001d4176f5d73e74f5f10f16b;hp=e6b10112b3ee661595f81aec7e1948bb4e8e0153 BaseTools: Add DefaultStore section format Check This patch add DefaultStore section format Check and it use same logic with SKUID section. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu Reviewed-by: Liming Gao --- diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 60fabf656c..bc77d1a2b4 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -608,6 +608,14 @@ class DscBuildData(PlatformBuildClassObject): if Record[1] in [None, '']: EdkLogger.error('build', FORMAT_INVALID, 'No DefaultStores ID name', File=self.MetaFile, Line=Record[-1]) + Pattern = re.compile('^[1-9]\d*|0$') + HexPattern = re.compile(r'0[xX][0-9a-fA-F]+$') + if Pattern.match(Record[0]) == None and HexPattern.match(Record[0]) == None: + EdkLogger.error('build', FORMAT_INVALID, "The format of the DefaultStores ID number is invalid. It only support Integer and HexNumber", + File=self.MetaFile, Line=Record[-1]) + if not IsValidWord(Record[1]): + EdkLogger.error('build', FORMAT_INVALID, "The format of the DefaultStores ID name is invalid. The correct format is '(a-zA-Z0-9_)(a-zA-Z0-9_-.)*'", + File=self.MetaFile, Line=Record[-1]) self.DefaultStores[Record[1].upper()] = (self.ToInt(Record[0]),Record[1].upper()) if TAB_DEFAULT_STORES_DEFAULT not in self.DefaultStores: self.DefaultStores[TAB_DEFAULT_STORES_DEFAULT] = (0,TAB_DEFAULT_STORES_DEFAULT) diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index 5ea14f8f10..d704809354 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -1105,7 +1105,7 @@ class DscParser(MetaFileParser): def _DefaultStoresParser(self): TokenList = GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT) if len(TokenList) != 2: - EdkLogger.error('Parser', FORMAT_INVALID, "Correct format is '|'", + EdkLogger.error('Parser', FORMAT_INVALID, "Correct format is '|'", ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1) self._ValueList[0:len(TokenList)] = TokenList