]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: Add DefaultStore section format Check
authorYonghong Zhu <yonghong.zhu@intel.com>
Mon, 22 Jan 2018 05:46:52 +0000 (13:46 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Tue, 23 Jan 2018 08:24:10 +0000 (16:24 +0800)
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 <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
BaseTools/Source/Python/Workspace/DscBuildData.py
BaseTools/Source/Python/Workspace/MetaFileParser.py

index 60fabf656c260456f64b30101c966e086aad6183..bc77d1a2b4390c5066165d9f51d008e0f4d0818f 100644 (file)
@@ -608,6 +608,14 @@ class DscBuildData(PlatformBuildClassObject):
                 if Record[1] in [None, '']:\r
                     EdkLogger.error('build', FORMAT_INVALID, 'No DefaultStores ID name',\r
                                     File=self.MetaFile, Line=Record[-1])\r
+                Pattern = re.compile('^[1-9]\d*|0$')\r
+                HexPattern = re.compile(r'0[xX][0-9a-fA-F]+$')\r
+                if Pattern.match(Record[0]) == None and HexPattern.match(Record[0]) == None:\r
+                    EdkLogger.error('build', FORMAT_INVALID, "The format of the DefaultStores ID number is invalid. It only support Integer and HexNumber",\r
+                                    File=self.MetaFile, Line=Record[-1])\r
+                if not IsValidWord(Record[1]):\r
+                    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_-.)*'",\r
+                                    File=self.MetaFile, Line=Record[-1])\r
                 self.DefaultStores[Record[1].upper()] = (self.ToInt(Record[0]),Record[1].upper())\r
             if TAB_DEFAULT_STORES_DEFAULT not in self.DefaultStores:\r
                 self.DefaultStores[TAB_DEFAULT_STORES_DEFAULT] = (0,TAB_DEFAULT_STORES_DEFAULT)\r
index 5ea14f8f1069d4fc467e2fe27e2cef4b5ed69516..d70480935460a3ef3dc4a2df9816153d923a8eb6 100644 (file)
@@ -1105,7 +1105,7 @@ class DscParser(MetaFileParser):
     def _DefaultStoresParser(self):\r
         TokenList = GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT)\r
         if len(TokenList) != 2:\r
-            EdkLogger.error('Parser', FORMAT_INVALID, "Correct format is '<Integer>|<UiName>'",\r
+            EdkLogger.error('Parser', FORMAT_INVALID, "Correct format is '<Number>|<UiName>'",\r
                             ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1)\r
         self._ValueList[0:len(TokenList)] = TokenList\r
 \r