]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: Add check for VOID* PCD Max Size
authorYonghong Zhu <yonghong.zhu@intel.com>
Fri, 3 Aug 2018 07:46:20 +0000 (15:46 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Fri, 17 Aug 2018 05:05:14 +0000 (13:05 +0800)
Per spec VOID* PCD max size should be a UINT16 value. so this patch
add the value check whether it is in range 0x0 .. 0xFFFF.

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

index e8b36a38684b3f7b11d2beb11e0a953d3d8c5855..c7f07f464646bb4390bbb690a00f1ab600283ac1 100644 (file)
@@ -1536,6 +1536,13 @@ class DscBuildData(PlatformBuildClassObject):
             if Setting is None:\r
                 continue\r
             PcdValue, DatumType, MaxDatumSize = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4)\r
+            if MaxDatumSize:\r
+                if int(MaxDatumSize, 0) > 0xFFFF:\r
+                    EdkLogger.error('build', FORMAT_INVALID, "The size value must not exceed the maximum value of 0xFFFF (UINT16) for %s." % ".".join((TokenSpaceGuid, PcdCName)),\r
+                                    File=self.MetaFile, Line=Dummy4)\r
+                if int(MaxDatumSize, 0) < 0:\r
+                    EdkLogger.error('build', FORMAT_INVALID, "The size value can't be set to negative value for %s." % ".".join((TokenSpaceGuid, PcdCName)),\r
+                                    File=self.MetaFile, Line=Dummy4)\r
             if (PcdCName, TokenSpaceGuid) in PcdValueDict:\r
                 PcdValueDict[PcdCName, TokenSpaceGuid][SkuName] = (PcdValue, DatumType, MaxDatumSize)\r
             else:\r
@@ -2381,6 +2388,13 @@ class DscBuildData(PlatformBuildClassObject):
                 continue\r
 \r
             PcdValue, DatumType, MaxDatumSize = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4)\r
+            if MaxDatumSize:\r
+                if int(MaxDatumSize, 0) > 0xFFFF:\r
+                    EdkLogger.error('build', FORMAT_INVALID, "The size value must not exceed the maximum value of 0xFFFF (UINT16) for %s." % ".".join((TokenSpaceGuid, PcdCName)),\r
+                                    File=self.MetaFile, Line=Dummy4)\r
+                if int(MaxDatumSize, 0) < 0:\r
+                    EdkLogger.error('build', FORMAT_INVALID, "The size value can't be set to negative value for %s." % ".".join((TokenSpaceGuid, PcdCName)),\r
+                                    File=self.MetaFile, Line=Dummy4)\r
             SkuInfo = SkuInfoClass(SkuName, self.SkuIds[SkuName][0], '', '', '', '', '', PcdValue)\r
             if (PcdCName, TokenSpaceGuid) in Pcds:\r
                 pcdObject = Pcds[PcdCName, TokenSpaceGuid]\r
@@ -2714,6 +2728,13 @@ class DscBuildData(PlatformBuildClassObject):
             # until the DEC parser has been called.\r
             #\r
             VpdOffset, MaxDatumSize, InitialValue = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4)\r
+            if MaxDatumSize:\r
+                if int(MaxDatumSize, 0) > 0xFFFF:\r
+                    EdkLogger.error('build', FORMAT_INVALID, "The size value must not exceed the maximum value of 0xFFFF (UINT16) for %s." % ".".join((TokenSpaceGuid, PcdCName)),\r
+                                    File=self.MetaFile, Line=Dummy4)\r
+                if int(MaxDatumSize, 0) < 0:\r
+                    EdkLogger.error('build', FORMAT_INVALID, "The size value can't be set to negative value for %s." % ".".join((TokenSpaceGuid, PcdCName)),\r
+                                    File=self.MetaFile, Line=Dummy4)\r
             SkuInfo = SkuInfoClass(SkuName, self.SkuIds[SkuName][0], '', '', '', '', VpdOffset, InitialValue)\r
             if (PcdCName, TokenSpaceGuid) in Pcds:\r
                 pcdObject = Pcds[PcdCName, TokenSpaceGuid]\r